Create a Lambda function that processes messages from an Amazon SQS queue, with event source mapping for automatic invocation.
https://docs.aws.amazon.com/lambda/latest/dg/with-sqs-example.html
- ID: lambda/sqs-trigger
- Phase: create
- Complexity: beginner
- Core actions: lambda:CreateFunction, lambda:CreateEventSourceMapping, sqs:SendMessage
- Creates an IAM execution role with SQS permissions
- Creates a Node.js Lambda function that logs message bodies
- Tests the function with a sample SQS event
- Creates an SQS queue
- Creates an event source mapping (queue → function)
- Sends test messages to the queue
- Verifies processing via CloudWatch Logs
- Cleans up all resources
bash lambda-sqs.shTo auto-run with cleanup:
echo 'y' | bash lambda-sqs.sh- IAM role (with AWSLambdaSQSQueueExecutionRole policy)
- Lambda function (Node.js 22)
- SQS queue
- Event source mapping
- CloudWatch log group (created automatically by Lambda)
- Run: ~45 seconds
- Cleanup: ~10 seconds
Free tier eligible. No charges expected for a few messages.