Amazon Simple Queue Service
Developer Guide

Tutorial: Configuring Messages Arriving in an Amazon SQS Queue to Trigger an AWS Lambda Function

In this tutorial you learn how to configure an existing Amazon SQS queue to trigger an AWS Lambda function when new messages arrive in a queue.

Lambda functions let you run code without provisioning or managing a server. For example, you can configure a Lambda function to process messages from one queue while another queue acts as a dead-letter queue for messages that your Lambda function can't process successfully. When you resolve the issue, you can redrive the messages from the dead-letter queue through the Lambda function. For more information see Amazon SQS Dead-Letter Queues and also What is AWS Lambda? and Using AWS Lambda with Amazon SQS in the AWS Lambda Developer Guide.


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.

You can't associate an encrypted queue that uses an AWS managed customer master key for Amazon SQS with a Lambda function in a different AWS account.


To configure Lambda function triggers using the console, you must ensure the following:

  • Your Amazon SQS role must include the following permissions:

    • lambda:CreateEventSourceMapping

    • lambda:ListEventSourceMappings

    • lambda:ListFunction

  • Your Lambda role must include the following permissions:

    • sqs:ChangeMessageVisibility

    • sqs:DeleteMessage

    • sqs:GetQueueAttributes

    • sqs:ReceiveMessage

For more information, see Overview of Managing Access Permissions to Your Amazon Simple Queue Service Resource.

AWS Management Console

  1. Sign in to the Amazon SQS console.

  2. From the list of queues, choose the queue which you want to trigger a Lambda function.

  3. From Queue Actions, select Configure Trigger for Lambda Function.

  4. In the Configure Incoming Messages to Trigger a Lambda Function dialog box, do one of the following:

    • To use an existing Lambda function, Select a Lambda Function from the list.

    • To create a new Lambda function in the AWS Lambda console, choose Create New. For more information, see Create a Simple Lambda Function in the AWS Lambda Developer Guide.

  5. Choose Save.

  6. In the Lambda Function Trigger Configuration Result dialog box, review the Lambda function that will be triggered by your Amazon SQS queue and choose OK.


    It takes approximately 1 minute for the Lambda function to become associated with your queue.

    The Lambda function and its status are displayed on the Lambda Triggers tab.

    • To verify the results of the configuration, you can send a message to your queue and then view the triggered Lambda function in the Lambda console.

    • To delete the association between a Lambda function and your queue, choose next to a Lambda function ARN.