IoT rule to Amazon SQS queue to AWS Lambda

IoT → SQS → Lambda

Create an IoT Rule with a SQS action and an AWS Lambda function.

When a message is published to the IoT topic defined in the IoT Rule, this message will be delivered to the SQS standard queue. The Lambda function is configured with an event source mapping and it will be triggered to process the messages in the queue. In this sample the Lambda function extracts the body of the message polled from the SQS queue and logs its content.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/iot-sqs-lambda-cdk

Deploy

cdk deploy


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

1. Delete the stack: npx cdk destroy.
2. Confirm the stack has been deleted: aws cloudformation list-stacks --query "StackSummaries[?contains(StackName,'STACK_NAME')].StackStatus".
3. You see a message confirming DELETE_COMPLETE.

Created by:

Patrick Malatesta

Patrick Malatesta

Cloud Infrastructure Architect at AWS Professional Services