ServerlessDatabase

Event-Driven Architectures with DynamoDB Streams and Lambda

NT

Naveen Teja

2/27/2026

Event-Driven Architectures with DynamoDB Streams and Lambda

Modern microservice architectures rely heavily on asynchronous, event-driven patterns. When an item in your database changes, other services—like search indexers, notification systems, or cache invalidators—need to react immediately without tightly coupling the application logic.

Amazon DynamoDB Streams captures a time-ordered sequence of item-level modifications in a DynamoDB table. By enabling streams and mapping them to an AWS Lambda function, you create a powerful trigger mechanism. Every Insert, Update, or Delete operation emits an event payload that the Lambda function can process in near real-time.

Setting this up requires enabling the stream on the DynamoDB table, provisioning the Lambda function, and creating an Event Source Mapping to bind them together. The Lambda execution role must also have the necessary permissions to read the stream records. Here is the Terraform required to link the stream to Lambda.

dynamodb-trigger.tf
resource "aws_lambda_event_source_mapping" "dynamodb_trigger" {
  event_source_arn  = aws_dynamodb_table.users.stream_arn
  function_name     = aws_lambda_function.process_user.arn
  starting_position = "LATEST"
  batch_size        = 100

  # Ensures Lambda retries on failure before discarding the event
  maximum_retry_attempts = 3
}