AWS in 1 Min · Episode 118

DynamoDB Streams explained: react to every change in your table

Every change, in order. Watch the one-minute video, then read the details.

David Gomez1:14 video · 3 min read

"To react to changes, keep polling the table." It works, badly. Every poll costs read capacity, most polls find nothing, and the ones that do find something are already late. DynamoDB Streams flips the direction: instead of asking the table what changed, the table tells you.

What a stream is

Turn on a stream for a DynamoDB table and DynamoDB keeps a change log. Every time an item is created, updated or deleted, it writes a stream record with the item's primary key, plus whatever extra detail you asked for.

The guarantees are what make it useful:

  • Each change appears exactly once in the stream (no duplicates).
  • Changes to the same item appear in the order they happened.
  • Records arrive in near real time.
  • The stream works asynchronously, so turning it on does not slow the table down.

One detail people miss: a PutItem or UpdateItem that doesn't actually change any data writes no stream record.

What each record holds

When you enable the stream you pick a view type, and you can't change it later without turning the stream off and on again:

  • Keys only: just the key attributes of the changed item.
  • New image: the whole item after the change.
  • Old image: the whole item before the change.
  • New and old images: both, so you can see exactly what changed.

Pick the smallest view that does the job. "New and old images" is handy for audit logs and diffs; "keys only" is enough when the consumer re-reads the item anyway.

Lambda triggers

The most common consumer is AWS Lambda. Add the stream as a trigger and Lambda polls it for you, invoking your function with batches of records, shard by shard, in order. Use cases: send a welcome email when a customer row appears, update a search index, keep a counter table in sync, or copy changes to another system. See Lambda triggers and event sources for how event source mappings work.

Lambda reading the stream through a DynamoDB trigger does not incur stream read (GetRecords) charges; you pay for the Lambda invocations. AWS lists an exception for functions on Lambda Managed Instances, where standard stream charges apply.

The 24-hour limit, and Kinesis

Stream records live for 24 hours, then they are trimmed. If your consumer is broken for longer than a day, those changes are gone from the stream. Alert on consumer errors and iterator age.

When you need more, DynamoDB can also send changes to Kinesis Data Streams:

  • Retention up to one year.
  • More consumers per shard (DynamoDB Streams recommends at most two readers per shard; Kinesis allows more, and even more with enhanced fan-out).
  • Feeds Firehose, Managed Service for Apache Flink and Glue streaming.
  • Trade-off: records can occasionally be duplicated, and you order them by timestamp, so consumers must be idempotent.

You can enable both on the same table.

Where AI fits

Streams turn a table into an event source for AI: trigger a model call on every change. A customer posts a review, the stream fires a Lambda, the function asks a model in Amazon Bedrock for a summary or sentiment score, and stores the result. The common mistake is writing that result back to the same item: that write is a change too, so it triggers the function again. Use Lambda event filtering (for example, only INSERT events), or write the result to a different table, so you don't build an expensive loop.

Quick recap

  • DynamoDB Streams records every insert, update and delete, exactly once, in order per item.
  • Lambda triggers process the changes in batches, with no stream read charges.
  • Records last 24 hours; use Kinesis Data Streams for longer retention and more consumers.
AWS in 1 Min #118 · 1:14

Need an AWS expert on your team?

I'm David, an AWS expert and fractional cloud consultant. I work alongside your team to run your cloud and infrastructure: architecture, security, cost and day-to-day operations. You get senior AWS experience when you need it, without the cost of a full-time hire.

  • Architecture reviews and a clear plan for what to fix first
  • Security hardening: IAM, networking, audits
  • Lower AWS bills without slowing your team down
  • Hands-on help with AI workloads on AWS