LinuxCommandLibrary

aws-dynamodbstreams

TLDR

List all streams associated with a DynamoDB table

$ aws dynamodbstreams list-streams --table-name [table_name]
copy
Describe a stream to get details and shards
$ aws dynamodbstreams describe-stream --stream-arn [arn:aws:dynamodb:region:account:table/name/stream/timestamp]
copy
Get a shard iterator to start reading records
$ aws dynamodbstreams get-shard-iterator --stream-arn [stream_arn] --shard-id [shard_id] --shard-iterator-type [TRIM_HORIZON|LATEST|AT_SEQUENCE_NUMBER]
copy
Read records from a shard
$ aws dynamodbstreams get-records --shard-iterator [iterator_string]
copy
Get shard iterator at a specific sequence number
$ aws dynamodbstreams get-shard-iterator --stream-arn [stream_arn] --shard-id [shard_id] --shard-iterator-type AT_SEQUENCE_NUMBER --sequence-number [seq_num]
copy

SYNOPSIS

aws dynamodbstreams subcommand [options]

DESCRIPTION

aws dynamodbstreams is a subcommand of the AWS CLI that reads change data capture records from DynamoDB Streams. When streams are enabled on a DynamoDB table, every modification (insert, update, delete) is captured as a stream record.
Streams organize records into shards, which are containers for sequenced records. To read stream data, you first obtain a shard iterator and then use it to retrieve records. Each shard iterator expires after 15 minutes of inactivity.
Stream records can include the old item image, new item image, or both, depending on the stream view type configured on the table. This enables use cases like replication, analytics, and triggering downstream workflows.

PARAMETERS

list-streams

List stream ARNs for a table or all tables.
describe-stream
Get stream metadata including shard information.
get-shard-iterator
Get an iterator for reading records from a shard.
get-records
Read stream records using a shard iterator.
--stream-arn arn
The Amazon Resource Name of the stream.
--table-name name
Filter streams by table name.
--shard-id id
The identifier of the shard to read.
--shard-iterator string
Iterator returned by get-shard-iterator.
--shard-iterator-type type
Where to start reading: TRIMHORIZON (oldest), LATEST (newest), ATSEQUENCENUMBER, or AFTERSEQUENCE_NUMBER.
--sequence-number number
Start at this sequence number (requires AT/AFTERSEQUENCENUMBER type).
--limit number
Maximum number of records to return.

CAVEATS

Shard iterators expire after 15 minutes. Stream records are retained for only 24 hours. Shards can split under high throughput, requiring logic to handle child shards. The get-records call may return empty results even when data exists due to internal shard mechanics; keep polling until the shard is closed.

HISTORY

DynamoDB Streams was announced at AWS re:Invent 2014 and became generally available in July 2015. It was designed to enable real-time processing of DynamoDB changes, complementing the introduction of AWS Lambda triggers for DynamoDB. The feature supports cross-region replication through Global Tables.

SEE ALSO

Copied to clipboard