AWS sqs limit to ec2 with iam role

北慕城南 提交于 2019-12-12 04:08:42

问题


I have an SQS to which i want to limit the access of services allowed to send/receive.

After reading and trying out I have found that this should be doable by using an Access Policy on the SQS.

The policy i wrote:

"Version": "2012-10-17",
  "Id": "arn:aws:sqs:eu-west-1:123456789:HACKsqs03/SQSDefaultPolicy",
  "Statement": [
{
  "Sid": "Sid456789",
  "Effect": "Allow",
  "Principal": {
    "AWS": "arn:aws:iam::123456789:role/HACKiam01"
  },
  "Action": "SQS:ReceiveMessage",
  "Resource": "arn:aws:sqs:eu-west-1:123456789HACKsqs03"
},
{
  "Sid": "Sid123456",
  "Effect": "Allow",
  "Principal": {
    "AWS": "arn:aws:iam::123456789:role/HACKiam02"
  },
  "Action": "SQS:SendMessage",
  "Resource": "arn:aws:sqs:eu-west-1:123456789:HACKsqs03"
}
]

This policy i attached to the SQS.

The two roles where added to two different EC2 instances which i used for testing. Now both where still able to send and receive messages. I can't figure out why?

Is my policy wrong? Or am I misunderstanding the documentation?

Clarification: I need a policy that allows one instance/securitygroup/iam-role to sendmessage and one instance/sg/iam-role to receive.


回答1:


There are other policies explicitly allowing things. Thanks to Jonh Rotenstein for pointing me in the right direction:

Follow up question



来源:https://stackoverflow.com/questions/45674218/aws-sqs-limit-to-ec2-with-iam-role

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!