AWS SQS lambda trigger disabled automatically

Viewed 5962

I have created aws SQS with lambda trigger. The issue I facing, is when message is send from sqs the lambda trigger automatically disconnected and also no log is generated in cloudwatch (log stream is generated). Anyone have any idea?

2 Answers

For SQS Lambda triggers,

Your Amazon SQS role must include the following permissions:

  1. lambda:CreateEventSourceMapping
  2. lambda:ListEventSourceMappings
  3. lambda:ListFunction

Your Lambda role must include the following permissions:

  1. sqs:ChangeMessageVisibility
  2. sqs:DeleteMessage
  3. sqs:GetQueueAttributes
  4. sqs:ReceiveMessage

Also Note,

  • Your queue and Lambda function must be in the same AWS Region.
  • FIFO queues don't support Lambda function triggers.
  • You can associate only one queue with one or more Lambda functions.

For logs, check if your lambda has below cloudwatch permissions for generating logs

  • logs:CreateLogGroup
  • logs:CreateLogStream
  • logs:PutLogEvents

I encountered this also. Ultimately the 'disabled' SQS/Lambda trigger seems like a symptom that could result from multiple root causes.

In my case it wasn't a permissions issue. The root cause was an issue with the 'event source mapping' that maps your SQS queue's 'EventSourceArn' to your Lambda function's 'FunctionArn'. I had deleted and recreated SQS queue with the same name. The result of this was the trigger being automatically disabled by AWS when the first SQS queue was deleted, but the mapping persisting in its 'disabled' state when the new queue was created.

The workaround here was just to manually delete the event source mapping. Once this was done, the 'disabled' trigger no longer persisted. There's a good answer/explanation on a related question here - https://stackoverflow.com/a/62392964/8577382

Related