Triggering Lambda from SQS

Length: 00:13:24

Lesson Summary:

In this lesson, we'll look at a common use case where we invoke a Lambda function that is triggered by SQS. Whenever a message is placed in the queue, the Lambda function will be triggered, reading the contents of that message and inserting its data as a record into DynamoDB.

Create a DynamoDB Table

aws dynamodb create-table --table-name Message \
  --attribute-definitions AttributeName=MessageId,AttributeType=S \
  --key-schema AttributeName=MessageId,KeyType=HASH \
  --billing-mode=PAY_PER_REQUEST

Create an SQS Queue

aws sqs create-queue --queue-name Messages

Sending Messages to SQS

Run the provided script send_message.py to send messages to SQS.

Example: Send a message containing random text to the Messages queue every 0.1 second (10 messages per second):

./send_message.py -q Messages -i 0.1

Press Ctrl+C to quit.

Send Messages to SQS: https://github.com/linuxacademy/content-lambda-boto3/tree/master/SQS/Triggering-Lambda-from-SQS

Faker: https://pypi.org/project/Faker/


This lesson is only available to Linux Academy members.

Sign Up To View This Lesson

Or Log In

Looking For Team Training?

Learn More