DynamoDB Streams lets you see changes made to your database in real time. It helps you react to data updates quickly and keep things in sync.
0
0
DynamoDB Streams concept
Introduction
You want to track every change made to your database items.
You need to update other systems automatically when your data changes.
You want to keep a backup or audit trail of all changes.
You want to trigger notifications or workflows when data updates happen.
You want to replicate data to another database or region.
Syntax
DynamoDB
Enable DynamoDB Streams on your table with a stream view type: - KEYS_ONLY - NEW_IMAGE - OLD_IMAGE - NEW_AND_OLD_IMAGES
The stream view type controls what data about the change is recorded.
Streams capture inserts, updates, and deletes on your table.
Examples
This records only the primary key attributes of changed items.
DynamoDB
Enable stream with KEYS_ONLY view type
This records the entire item after the change.
DynamoDB
Enable stream with NEW_IMAGE view type
This records the entire item before the change.
DynamoDB
Enable stream with OLD_IMAGE view type
This records both the item before and after the change.
DynamoDB
Enable stream with NEW_AND_OLD_IMAGES view type
Sample Program
This command enables DynamoDB Streams on the 'MusicCollection' table. It records both the old and new versions of items when they change.
DynamoDB
aws dynamodb update-table \ --table-name MusicCollection \ --stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES
OutputSuccess
Important Notes
Enabling streams may slightly increase your costs because of extra storage and processing.
You can use AWS Lambda to automatically process stream records as they arrive.
Stream records are kept for 24 hours before they expire.
Summary
DynamoDB Streams capture changes to your table in real time.
You choose what data to capture using stream view types.
Streams help you build reactive and synchronized applications.