SQS的AWS IAM策略

时间:2014-03-24 17:57:45

标签: amazon-web-services amazon-sqs amazon-iam

我正在尝试向现有的iam用户添加策略,该用户已经可以在两个s3存储桶上执行crud,这是当前正在运行的策略

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "devcontrol",
      "Effect": "Allow",
      "Action": [
        "s3:Get*",
        "s3:Put*",
        "s3:DeleteObject",
        "s3:DeleteObjectVersion"
      ],
      "Resource": [
        "arn:aws:s3:::blahimages/*",
        "arn:aws:s3:::blahvideos/*"
      ]
    }
  ]
}

来自sqs文档的示例策略是

{
   "Version": "2012-10-17",
   "Statement":[{
      "Effect":"Allow",
      "Action":"sqs:*",
      "Resource":"arn:aws:sqs:*:123456789012:bob_queue*"
      }
   ]
}

所以我试过这个

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "devcontrol",
      "Effect": "Allow",
      "Action": [
        "s3:Get*",
        "s3:Put*",
        "s3:DeleteObject",
        "s3:DeleteObjectVersion"
       ],
       "Resource": [
         "arn:aws:s3:::blahimages/*",
         "arn:aws:s3:::blahvideos/*"
        ]
     },
     {
       "Effect":"Allow",
       "Action":"sqs:*",
       "Resource":"arn:aws:sqs:*:myarn"
      }
    ]
  }

我没有得到任何解析错误,但模拟器仍然拒绝为sqs队列

另外,我真的希望此用户能够将消息添加到队列,接收并删除它们,而上述策略将添加我认为的所有操作

1 个答案:

答案 0 :(得分:5)

您的SQS ARN无效:"arn:aws:sqs:*:myarn"

您应该使用arn:aws:sqs:<region name>:<account id>:<queue name>代替。 (你错过了<account id>)。

如果您希望自己的政策在多个地区有效,则地区名称可能会被*替换。但是帐户ID是必需的,因为队列名称在AWS主帐户和区域中是唯一的。

有关有效的SQS政策,请参阅http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/SQSExamples.html