Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS IAM policy for SQS

I am trying to add a policy to an existing iam user that can already perform crud on two s3 buckets here is the currently working policy

{
  "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/*"
      ]
    }
  ]
}

An example policy from the documents for sqs is this

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

So I tried this

{
  "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"
      }
    ]
  }

I did not get any parse errors but the simulator was still returning denied for the sqs queue

Also really I just want this user to be able to add messages to the queue, receive them and delete them whereas the above policy would add all actions I believe

like image 258
Mark Avatar asked Mar 24 '14 17:03

Mark


People also ask

What is default policy for SQS?

The default policy allows only the queue owner to send and receive messages. Open the Amazon SQS console at https://console.aws.amazon.com/sqs/ . In the navigation pane, choose Queues. Choose a queue and choose Edit.

How do I allow access to SQS?

Attach a permission policy to a user in another AWS account – To grant user permissions to create an Amazon SQS queue, attach an Amazon SQS permissions policy to a user in another AWS account. Cross-account permissions don't apply to the following actions: AddPermission. CreateQueue.

Can an SQS queue have multiple policies?

The aws documentation for SQS says multiple policies could be applied to a single queue; however the cloudformation QueuePolicy does not have explicit mention on whether this is allowed or not.

Is SQS fully managed?

Amazon SQS (Simple Queue Service) is a fully managed service popular for its message queuing functionality. Developers often send and retrieve messages of various types and sizes asynchronously using this service. Amazon SQS empowers you to keep individual microservices and distributed systems separate from each other.


1 Answers

Your SQS ARN is invalid : "arn:aws:sqs:*:myarn".

You should use arn:aws:sqs:<region name>:<account id>:<queue name> instead. (you're missing the <account id>).

The region name might be replaced by a * if you want your policy to be valid in multiple regions. But the account id is mandatory as Queue names are unique within an AWS Master Account and Region only.

See http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/SQSExamples.html for example of valid SQS policies.

like image 127
Sébastien Stormacq Avatar answered Oct 06 '22 10:10

Sébastien Stormacq