我正在尝试将SNS主题添加到s3存储桶中,并且我使用aws cli命令将通知配置应用于名为“test”的s3bucket
我将SNS主题配置作为json字符串传递,当我尝试打印json字符串时,它正确地打印json值,但不知何故aws cli为json字符串添加逗号。
inputevent.sh:
#!/bin/bash
bucketName=test
jsonInput=file:///Users/ish/GitLabProject/validator-cf/inputevent.json
QueueArn="arn:aws:sns:us-east-1:255353535355:SNSTopic"
template='{ "TopicConfigurations": { "Event": "s3:ObjectCreated:*", "Queue": "%s" } }'
TopicConfiguration=$(printf "$template" "$QueueArn")
echo "$TopicConfiguration"
aws s3api put-bucket-notification-configuration --bucket $bucketName --notification-configuration $TopicConfiguration
错误:
{ "TopicConfigurations": { "Event": "s3:ObjectCreated:*", "Queue": "arn:aws:sns:us-east-1:255353535355:SNSTopic" } }
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
Unknown options: {, "Event":, "s3:ObjectCreated:*",, "Queue":, "arn:aws:sns:us-east-1:255353535355:SNSTopic", }, }, "TopicConfigurations":