- Lab
- A Cloud Guru
Triggering AWS Lambda from Amazon SQS
In this hands-on AWS lab, you will learn how to trigger a Lambda function using SQS. This Lambda function will process messages from the SQS queue and insert the message data as records into a DynamoDB table.
Path Info
Table of Contents
-
Challenge
Create the Lambda Function
- Navigate to Lambda.
- Select Create a function.
- Give the function the name SQSDynamoDB.
- Under Runtime, choose Python 3.9.
- Select the Use an existing role and select lambda-execution-role.
- Click Create function.
-
Challenge
Create the SQS Trigger
- Click Add trigger.
- Search for SQS and select it.
- Under SQS queue, select Messages.
- Leave the rest as default, and ensure Enable trigger is selected.
- Click Add.
-
Challenge
Copy the Source Code into the Lambda Function
- Open the lambda function code by double-clicking lambda_function.py.
- Paste in the source code from here.
- Deploy the Lambda function.
-
Challenge
Log In to the EC2 Instance and Test the Script
- Connect to the EC2 instance as shown.
- Run
su - cloud_user
. - Run
./send_message.py -q Messages -i 0.1
.
-
Challenge
Confirm Messages Were Inserted into the DynamoDB Table
- Open the DynamoDB console.
- Open the Message table.
- Open the Items tab.
- Confirm Items is populated.
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.