-
Notifications
You must be signed in to change notification settings - Fork 17
Role associated with lamba doesn't have permission to SQS queue #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I had a few iterations trying to figure out the policy as well. With the proposal from #10 there might be a more simplified syntax that would compile the queue resource and policy document for you. Until then here is the syntax I used in the custom resources... I can't say which one of these is causing your issue but I noticed a few differences:
Let me know if this works for you. functions:
serverlessLambda:
name: my-serverless-lambda
description: Lambda to test the serverless utility
deadLetter:
# Use the ARN of a resource defined in the resources section.
targetArn:
GetResourceArn: ServerlessTplLambdaDlQueue
resources:
Resources:
ServerlessTplLambdaDlQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: my-serverless-lambda-retry-queue
ServerlessTplLambdaDlQueuePolicy:
Type: AWS::SQS::QueuePolicy
Properties:
Queues:
- Ref: ServerlessTplLambdaDlQueue
PolicyDocument:
# This probably needs something more unique
# like 'Fn::GetAtt: [ServerlessTplLambdaDlQueue, Arn]' + '/SQSPolicy'
Id: ServerlessTplLambdaDlQueueId
Version: '2012-10-17'
Statement:
- Sid: Allow-Lambda-SendMessage
Effect: Allow
Principal:
AWS: "*"
Action:
- SQS:SendMessage
Resource:
Ref: ServerlessTplLambdaDlQueue
Condition:
ArnEquals:
aws:SourceArn:
Fn::GetAtt: [ServerlessLambdaLambdaFunction, Arn] |
Interesting. I was under the impression all that was needed was a QueuePolicy, but perhaps the lambda role needs general SQS permission. In my I'm using an existing IAM role that probably has something like Have you tried setting the I need to research a little bit and see if there are analogous scenarios. Do you know if serverless adds SNS or S3 access to the |
@AirEssY I've release version 1.2.0 the syntax should be simplified and it will eliminate the need to create the queue or policy in the Your Lambda will still need a role that has SQS permissions though. |
On second thought i need to do some more investigation on this. According to the docs serverless can create a default IAM role with rights to some resources. In my environment I am required to use a predefined |
IMHO, you like won't be creating roles in an enterprise environment. A devops will provide that to you, as in my case. The strange thing is that I had to put this permission on the role rather than the user that is running it. I suppose that is because the Lambda is what needs the SQS perms to publish to it out of EC2, so you need to add |
Using this plugin (Awesome, love it!) and I can't seem to get the role configuration to work properly.
So here's an extract from my serverless.yml
The SQS is getting created with these permissions (I've really opened it up just to get it to work, then i'll scale it back correctly once i accomplish that)

(Im not even sure if I need to give the above policy document, I would have thought permission would come from the functions ROLE, much like how the Kinesis stream permissions work, through the role)
The SQS is being associated correctly to the lambda function:

However as you can see I have a warning that the Role does not have permissions to that SQS queue
I've got a role being created with the following inline policy which can correctly access the Kinesis stream I have asked it subscribe to, and to CloudWatch in general...
I would have assumed that the above general policy would also specific access to the SQS DLQ, but it does not?
The text was updated successfully, but these errors were encountered: