DynamoDB Streams and Global Tables
Process item-level changes in real time with Streams and replicate data across Regions with global tables for low-latency reads worldwide.
DynamoDB Streams: Change Data Capture
DynamoDB Streams captures a time-ordered sequence of item-level modifications in a DynamoDB table. Every time an item is created, updated, or deleted, DynamoDB writes a stream record describing the change. Stream records are available for 24 hours after they are written.
Streams are the foundation of event-driven architectures with DynamoDB. Common uses include triggering Lambda functions for real-time processing, maintaining an audit log, replicating data to another store, or invalidating a cache when data changes.
# Enable a DynamoDB Stream on an existing table
aws dynamodb update-table \
--table-name Orders \
--stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGESStream View Types
When enabling a stream, you choose a StreamViewType that determines what data each stream record contains:
- KEYS_ONLY: only the primary key attributes of the modified item
- NEW_IMAGE: the entire item as it appears after the change
- OLD_IMAGE: the entire item as it appeared before the change
- NEW_AND_OLD_IMAGES: both the before and after state of the item
Choose NEW_AND_OLD_IMAGES for auditing (to see what changed), NEW_IMAGE for replication or cache updates, and KEYS_ONLY when you only need to know which item changed and will fetch the current state separately.
All lessons in this course
- Tables, Items, and Primary Keys
- Provisioned vs On-Demand Capacity
- Global Secondary Indexes and Local Secondary Indexes
- DynamoDB Streams and Global Tables