Why isn't my Lambda function triggered even though it's configured with SQS as the event source?
I've configured my AWS Lambda function to process messages in an Amazon Simple Queue Service (Amazon SQS) queue. But my Lambda function isn't invoked and doesn't process messages in the queue.
"I've configured my AWS Lambda function to process messages in an Amazon Simple Queue Service (Amazon SQS) queue. But my Lambda function isn't invoked and doesn't process messages in the queue.ResolutionFirst confirm that the Lambda function is configured with Amazon SQS as the event source. Then, confirm that the Lambda function's execution role has the permissions it needs to fetch messages from the SQS queue.Check the Amazon CloudWatch metrics for your function for invocations. If you still don't see any invocations on the Lambda function, then use the following troubleshooting steps to find the root cause.Check that the Lambda function and SQS queue URLs are correctConfirm that the Lambda function URL and the SQS queue URL in the event source mapping on the Lambda function are correct. Also, make sure that event source mapping is turned on.1.    Navigate to the function page ( $Latest/specific version/Alias), and then choose the SQS trigger in the UI. This lists the triggers.2.    Expand the SQS trigger, and check if the SQS queue URL matches the expected queue. Also, confirm if the trigger status is Enabled.3.    If the trigger is not turned on, then choose Edit, and then set the trigger back to the Enabled state.-or-Perform these checks by calling the list-event-source-mapping command in Lambda. Be sure to add the --function-name to the command.See the following example:aws lambda list-event-source-mappings --function-name <my-function> --region <region-name>Note: Replace <my-function> and <region name> with the names of your Lambda function and AWS Region.Check the Lambda function permissionsIf the Lambda execution role has permission to poll messages from the SQS queue, then check the SQS queue's access policy. Look for deny rules that might be blocking the Lambda function from accessing the queue and fetching messages.1.    Log in to the Amazon SQS console, and then choose Access Policy.2.    Check if there are any deny policies blocking the traffic from Lambda. Then, add a condition in the deny statement to ignore requests coming from Lambda when denying requests to the SQS queue.Check if the SQS queue is encryptedConfirm if the SQS queue is encrypted with an AWS Key Management Service (AWS KMS) key. If the queue is encrypted, then the Lambda function's execution role needs the permissions to perform AWS KMS actions. Without these permissions, the Lambda function can't consume messages from the SQS queue.Check if the specific Lambda function is observing throttlesLambda has a Regional concurrency limit. If other functions in the Region actively use this capacity to its maximum, then throttles can occur on the function. This can happen even if the function itself is not reaching the maximum capacity.If you set a reserved concurrency on the function, then no invocations occur on the function and all messages from Amazon SQS are throttled.Check the Regional ConcurrentExecutions (maximum) metric, and the function's Throttle (SUM) metrics in Amazon CloudWatch. Verify whether the Regional capacity is reached and whether there are any throttles on the function. Make sure that there's enough capacity for the function to be invoked and process SQS messages.Confirm that there are no other active consumers on the same SQS queueIf there is more than one active customer on the SQS queue, then your messages might be consumed by these customers. SQS messages are designed to be consumed by only one customer at a time. So, if another customer is consuming the SQS queue, then your Lambda function might not receive any messages when it polls the SQS queue.Verify whether any other Lambda triggers or Amazon Simple Notification Service (Amazon SNS) triggers are active in your SNS queue using the Amazon SQS console.Note: Other customers might be pulling messages from the SNS queue programmatically. These pulls don't appear in the console.Check if Lambda function and SQS are in different Regions of the same accountLambda allows you to configure only same-Region SQS queues as the source in event source mapping.Check if the Lambda function and SQS are in different accountsWith Lambda, your Lambda function and SQS queue can exist in different AWS accounts as long as they're in the same AWS Region. But, you might need additional permissions and configurations to work with this cross-account setup.Check if the SQS event source is configured with filtersCheck if the SQS event source is configured with any filters. If your SNS event source is configured with filters, then make sure that the filters aren't filtering out some or all Amazon SQS messages.1.    Log in to the Lambda function console, and then choose the SQS trigger.2.    Expand the SQS trigger configuration, and then verify the Filter criteria. If the trigger configuration doesn't show they key name, then this indicates that no filter is configured.3.    If a filter criteria is configured, then review the filter to confirm that it's allowing valid messages to be processed by Lambda.4.    To temporarily remove the filter criteria, choose Edit beside the SQS trigger details.5.    If the function is invoked after you remove the filter, then modify the filter criteria to match your use case.For more information, see Properly filtering Amazon SQS messages and Best practices for implementing Lambda event filtering.Further troubleshootingIf your function is invoked but isn't scaling as expected and is causing a backlog in your queue, then see Why isn't my Lambda function with an Amazon SQS event source scaling optimally?If your function is invoked but certain messages go to the dead-letter queue (DLQ) without being processed, then see Why is my Lambda function retrying valid Amazon SQS messages and placing them in my dead-letter queue?Related informationUsing Lambda with Amazon SQSFollow"