CodexBloom - Programming Q&A Platform

how to Get AWS SQS Messages to Trigger AWS Lambda Function Using Python SDK

πŸ‘€ Views: 1 πŸ’¬ Answers: 1 πŸ“… Created: 2025-06-06
AWS Lambda SQS Boto3 Python

I'm trying to configure I'm working with an scenario where messages in my AWS SQS queue are not triggering my Lambda function as expected. I've set up an event source mapping using the AWS SDK for Python (Boto3) to connect my SQS queue to the Lambda function, but it seems like the messages are piling up in the queue instead of being processed. I've verified that the Lambda function is configured correctly and has the necessary permissions to poll the SQS queue. The Lambda execution role has the `AWSLambdaSQSQueueExecutionRole` policy attached, which should allow it to read messages from SQS. However, when I check the CloudWatch logs for my Lambda function, I see no invocations occurring. Here is the code snippet I used to create the event source mapping: ```python import boto3 sqs = boto3.client('sqs') lambda_client = boto3.client('lambda') queue_url = 'https://sqs.us-west-2.amazonaws.com/123456789012/my-queue' function_name = 'myLambdaFunction' response = lambda_client.create_event_source_mapping( EventSourceArn=queue_url, FunctionName=function_name, Enabled=True, BatchSize=10, ) print(response) ``` I've double-checked the ARN of the SQS queue, and it looks correct. I also made sure that the queue's redrive policy is not affecting the visibility timeout. I tried setting the batch size to 1, but that didn’t help either. Additionally, I inspected the Lambda function's trigger settings in the AWS Management Console, and it appears that the event source mapping is indeed created. However, the messages still remain in the queue without being processed. I also checked for any CloudWatch alarms or Lambda throttling, but none are triggering. Does anyone have suggestions for troubleshooting this scenario? Is there a possibility that I missed a specific configuration or permission that’s causing this behavior? Any suggestions would be helpful.