AWS DynamoDB Support
DynamoDB TTL and Streams setup.
TTL deletes expired items for free, but not at the exact second, and Streams can react to those deletes. Most problems come from a wrong attribute format, expecting instant deletion, or Lambda stream consumers that retry forever on a bad record. We set both up and make them safe.
When You Need This
The situations where this work pays for itself.
Signs it is time
- TTL is enabled but expired items are still there
- You need to archive or clean up data when items expire
- A Lambda stream consumer is stuck retrying one bad record
- You want change data capture from DynamoDB to another system
- Reads return items you consider expired
What you get
- Verified TTL configuration and attribute format
- Streams and Lambda consumer in infrastructure as code with failure handling
- Archive-to-S3 pipeline for expired items if needed
- Iterator age and error alarms
How we do it
A clear, safe process you can follow along with.
1. Check the TTL attribute
The TTL attribute must be a Number holding a Unix epoch time in seconds, not milliseconds and not a string or date. A value in milliseconds looks like a time far in the future and never expires.
2. Understand the delay
Items are deleted in the background some time after expiry, which can be hours or longer. Reads can still return an expired item, so we add a filter on the TTL attribute in queries where correctness matters.
3. Enable Streams with the right view
We choose the stream view type, such as NEW_AND_OLD_IMAGES, that gives consumers what they need. Stream records are available for 24 hours.
4. Identify TTL deletions in the stream
Deletes made by TTL appear in the stream with a service principal in userIdentity, so a consumer can archive them to S3 and ignore deletes made by users.
5. Build the Lambda consumer safely
We set batch size, enable partial batch response, add a retry limit and an on-failure destination, since a poison record can otherwise block a shard until it expires from the stream.
6. Filter events
Event source mapping filters let Lambda receive only the records you need, which lowers cost and noise.
7. Monitor
We alarm on iterator age, Lambda errors and the age of oldest items past TTL to catch a stuck consumer or misconfigured attribute.
Mistakes we help you avoid
Common ways this goes wrong, and what we do instead.
Storing TTL in milliseconds
The item looks like it expires in the far future and is never removed.
Relying on TTL for exact deadlines
Deletion is eventual. Filter expired items in reads.
No failure destination on the consumer
One bad record can stall the shard and delay all processing behind it.
Frequently Asked Questions
Why are my DynamoDB items not deleted after TTL?
Check the attribute is a Number in epoch seconds and TTL is enabled. Even then, deletion is a background process that may take time, so expired items can linger.
Does TTL deletion use write capacity?
TTL deletes do not consume write capacity on the table, though replicas, indexes and streams are affected in their own ways. Check current documentation for details.
How long does DynamoDB keep stream records?
Stream records are kept for 24 hours, so consumers must process them within that window or you lose them.
Want Help With DynamoDB TTL and Streams setup?
Schedule an appointment. Tell us about your environment and we will outline the safest, highest-value approach.
Schedule Appointment › No commitment required