Processing DynamoDB Streams Using Lambda

1 hour
  • 3 Learning Objectives

About this Hands-on Lab

In this lab, we will create a Lambda function to process DynamoDB stream data from an existing table that is actively being written to. Once processed, the data from the stream will be aggregated and written to a second DynamoDB table.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create Lambda Function to Process Stream Events
  1. Log in to the AWS Management Console for the lab environment using the credentials provided.
  2. Navigate to Lambda.
  3. Create a new Lambda function and write/paste the code (found on GitHub) to process DynamoDB Streams events.
Create DynamoDB Streams Trigger
  1. Create a new trigger for your function, setting DynamoDB as the trigger type, and provide the appropriate configuration information.
  2. Enable trigger on creation to start processing stream events into stats aggregation table.
Verify Stream Processing

Navigate to DynamoDB to verify statistics are correctly aggregated and written to the stats table.

Additional Resources

The Linux Academy AWS Training Architects have gotten together at a company retreat and are engaged in a video game tournament. Mark Richman and John Hanna (hi, that's me!) have created a simple utility to log game, player, date time, and score information to a table named TaTourney. There is a stream enabled on TaTourney, and a second table has been created called TaTourneyStats that has a partition key of player. They would like secondary attributes of avg_score, wins, and win_percent to be aggregated from the data in the TaTourney stream.

We will need to create a Lambda function to process the data from the DynamoDB stream associated with the TaTourney table, as well as a DynamoDB Lambda trigger to trigger the function based on DynamoDB stream activity.

The code used for the solution in this lab can be found on GitHub.

Reference

DynamoDB Streams

What are Hands-on Labs

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.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?