[英]Setting S3 to post notifications to SQS when new item is created
我正在尝试做(应该是)一个简单的任务。
我在附加两个方面陷入困境。
我已经创建了队列,并且运行良好。 我已经创建了存储桶,它运行良好。
现在,我正在尝试将策略添加到队列中,以使存储桶发送通知。
遵循本指南:
http://docs.aws.amazon.com/AmazonS3/latest/dev/ways-to-add-notification-config-to-bucket.html
我正在尝试调用此方法:
public SetQueueAttributesResponse SetQueueAttributes(Dictionary<string, string> attributes)
{
var setQueueAttributesRequest = new SetQueueAttributesRequest()
{
QueueUrl = QueueUri.ToString(),
Attributes = attributes
};
return SqsClient.SetQueueAttributes(setQueueAttributesRequest);
}
并且attribute属性具有单个键/值对:
Policy
{
"Version" : "7/5/2017",
"Id" : "S3-Post",
"Statement" : [
{
"Sid" : "S3-Post",
"Effect" : "Allow",
"Principal" : {
"AWS" : "*"
},
"Action" : [
"sqs:SendMessage",
"sqs:GetQueueUrl"
],
"Resource" : "arn:aws:sqs:us-west-2:[REDACTED]:testqueue2",
"Condition" : {
"ArnLike" : {
"aws:SourceArn" : "arn:aws:s3:*:*:*"
}
}
}
]
}
(是的,我稍微扩大了过滤条件,但是在建立存储桶名称时也遇到了同样的问题。)
我得到这个例外:
Amazon.SQS.AmazonSQSException未处理
错误码= InvalidAttributeValue
的HResult = -2146233088
Message =参数Policy的值无效。
的requestId = 0ac6201a-17f5-5b63-a5ac-71cd42b10481
来源= AWSSDK.Core
谁能看到我的错误,或者有人可以向我指出一个更实用的示例?
Version
是指所使用的IAM策略语言的版本,而不是您的策略的修订版。
您只想使用一个值: "2012-10-17"
。
http://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html#Version
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.