dnl*_*tsk 5 amazon-s3 amazon-sqs amazon-web-services
我想将s3:CreateObject:*事件发送到SQS队列。但是设置通知配置会导致A client error (InvalidArgument) occurred when calling the PutBucketNotificationConfiguration operation: Unable to validate the following destination configurations
这是我创建存储桶的方式:
aws s3api create-bucket --profile default --bucket my-bucket --create-bucket-configuration LocationConstraint=eu-west-1
Run Code Online (Sandbox Code Playgroud)
这就是我创建SQS队列的方式
aws sqs create-queue --profile default --queue-name my-queue --attributes file://attributes.json
Run Code Online (Sandbox Code Playgroud)
与attributes.json文件
{
"DelaySeconds":"0",
"MessageRetentionPeriod":"3600",
"Policy":"{\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":\"*\",\"Action\":[\"sqs:SendMessage\",\"sqs:ReceiveMessage\"],\"Condition\":{\"ArnLike\": {\"aws:SourceArn\": \"arn:aws:s3:*:*:my-bucket\"}}}]}"
}
Run Code Online (Sandbox Code Playgroud)
最后,尝试设置引发我上面列出的错误消息的通知:
aws s3api put-bucket-notification-configuration --profile default --bucket my-bucket --notification-configuration file://notification.json`
Run Code Online (Sandbox Code Playgroud)
与notification.json文件一起使用
{
"TopicConfigurations": [
],
"QueueConfigurations": [
{
"QueueArn": "arn:aws:sqs:eu-west-1:123456789012:my-queue",
"Events": [
"s3:ObjectCreated:*"
],
"Filter": {
"Key": {
"FilterRules": [
{
"Name": "prefix",
"Value": "my-filter"
}
]
}
}
}
],
"LambdaFunctionConfigurations": [
]
}
Run Code Online (Sandbox Code Playgroud)
我真的不知道错误可能在哪里。谢谢你的帮助!
您的 SQS 政策似乎不起作用。尝试添加Id到您的政策和Resource声明中。像这样的东西:
{
"DelaySeconds":"0",
"MessageRetentionPeriod":"3600",
"Policy":"{\"Id\":\"someid\",\"Statement\":[{\"Effect\":\"Allow\",\"Resource\": \"arn:aws:sqs:eu-west-1:123456789012:my-queue\",\"Principal\":\"*\",\"Action\":[\"sqs:SendMessage\",\"sqs:ReceiveMessage\"],\"Condition\":{\"ArnLike\": {\"aws:SourceArn\": \"arn:aws:s3:*:*:my-bucket\"}}}]}"
}
以下是更多信息:
另外,当从命令行调用 API 时,您可以使用 --debug 参数。您将看到完整的错误消息:
aws --debug s3api ...
| 归档时间: |
|
| 查看次数: |
4933 次 |
| 最近记录: |