I have been successfully putting IAM role statements in my serverless.yml for S3 access for some time and assumed everything would work similarly when I added SQS. I took the very simple arn:aws:s3::: and replaced the s3 with SQS, as you can see below:
iam:
role:
statements:
- Effect: 'Allow'
Action:
- 's3:ListBucket'
Resource:
Fn::Join:
- ''
- - 'arn:aws:s3:::'
- mahtestbucket
- Effect: 'Allow'
Action:
- 's3:GetObject'
Resource:
Fn::Join:
- ''
- - 'arn:aws:s3:::'
- mahtestbucket
- '/*'
- Effect: 'Allow'
Action:
- 's3:ListBucket'
Resource:
Fn::Join:
- ''
- - 'arn:aws:s3:::'
- mahfailbucket
- Effect: 'Allow'
Action:
- 's3:PutObject'
Resource:
Fn::Join:
- ''
- - 'arn:aws:s3:::'
- mahfailbucket
- '/*'
- Effect: 'Allow'
Action:
- 'sqs:SendMessage'
- 'sqs:GetQueueUrl'
- 'sqs:GetQueueAttributes'
Resource:
Fn::Join:
- ''
- - 'arn:aws:sqs:::'
- mahqueue
This deploys with no errors. I can see the policy statement but it just doesn't work. The lambda function fails when it attempts to access the SQS resource.