How do I capture Amazon DynamoDB global table stream events with AWS Lambda?

2 minute read
0

I want to create an AWS Lambda trigger to process a stream from an Amazon DynamoDB global table.

Resolution

DynamoDB global tables are a collection of replica tables spread across AWS Regions in a single AWS account. Global tables use Amazon DynamoDB Streams to replicate data across different Regions. When you create a replica for a global table, a stream is created by default. Changes to one replica are propagated to all other replicas within the same global table by DynamoDB Streams. The replications typically occur within one second.

Note: To retrieve the modification records for all items, you need only one consumer on a global table replica in a single Region.

To configure an AWS Lambda trigger to process a stream from a global table replica, complete the following steps:

  1. Be sure that the policy AWSLambdaDynamoDBExecutionRole has the necessary AWS Identity and Access Management (IAM) permissions.
    Note: By default, the AWSLambdaDynamoDBExecutionRole IAM policy doesn't have permissions for Lambda to communicate with other services, such as Amazon Simple Notification Service (Amazon SNS). You must add the required additional permissions based on the Lambda target.
  2. To create a Lambda function, use the blueprint Process updates made to a DDB table. If necessary, modify the Lambda code so that it processes stream data to meet your requirements.
  3. Open the DynamoDB console of your Lambda function, and then select the global table replica.
  4. In the Exports and streams tab, choose Create trigger.
  5. Select the Lambda function that you created. Select Enable trigger.

The Lambda function is now configured as a trigger for your global table replica. Changes to the replica are now captured by the stream, and invoke the trigger.

Related information

DynamoDB Streams and AWS Lambda triggers

AWS OFFICIAL
AWS OFFICIALUpdated 9 months ago