DynamoDB Stream — Batch Processing
A Lambda function that handles INSERT/MODIFY/DELETE events on items of a source DynamoDB table by batch processing the records and upserting/deleting processed items into/from a destination DynamoDB table. Partial batch failure reporting is enabled so that individual record failures do not cause the entire batch to be retried.
Architecture
The template sets up:
- Source Amazon DynamoDB Stream: Provides the stream of data events.
- AWS Lambda function: Batch processes stream records with partial failure reporting.
- Destination Amazon DynamoDB table: Stores the processed output.

Code
- Function code:
templates/stream - Unit tests:
tests/stream - Infra stack:
infra/stacks/stream.py
Deployment
Deploy the stack using:
mise run deploy stream
Data models
SourceItem
Read from the source table stream.
| Field | Type | Description |
|---|---|---|
id |
string | Unique item identifier (1-50 chars) |
name |
string | Human-readable item name (optional, 1-100 chars) |
DestinationItem
Written to the destination table.
| Field | Type | Description |
|---|---|---|
id |
string | Unique item identifier (1-50 chars) |
name |
string | Human-readable item name (optional, 1-100 chars) |
Environment variables
| Variable | Description | Required | Default |
|---|---|---|---|
SOURCE_TABLE_NAME |
Source DynamoDB table name (stream source) | Yes | - |
DESTINATION_TABLE_NAME |
Destination DynamoDB table name | Yes | - |
SERVICE_NAME |
Powertools service name | No | dynamodb-stream |
METRICS_NAMESPACE |
Powertools metrics namespace | No | DynamoDBStream |
LOG_LEVEL |
Log level for the Lambda Logger | No | INFO |