DynamoDB TTL automatically deletes items after a timestamp you set, at no extra cost. It’s the clean way to expire old data — sessions, temporary records, event data — without running your own cleanup jobs.
The tell
When a scenario needs to automatically remove expired items from a DynamoDB table (session data, logs older than X days) without extra cost or custom deletion code, that’s TTL. You store an expiry timestamp attribute and DynamoDB deletes items past it.
DynamoDB TTL: exam traps
- Use a numeric Unix epoch timestamp: configure the table with the name of the expiry attribute; each item can then carry its own expiration time.
- Deletion is asynchronous: an expired item may remain visible for a period before DynamoDB removes it. Do not use TTL as an exact-time scheduler or immediate authorization control.
- TTL is for cleanup, not query filtering: applications should still handle expired records correctly during the interval before physical deletion.
- Cost and streams: TTL itself does not incur a separate deletion charge, but deletion effects and downstream processing can still matter; TTL deletions may appear in DynamoDB Streams as service deletions.
- Exam clue: for automatic eventual cleanup of old sessions or temporary records without writing a scheduled delete job, TTL is a likely fit. For immediate removal at a precise deadline, design additional application logic.
Test yourself
A DynamoDB table stores user sessions that should be automatically removed 24 hours after creation, with no cleanup job to maintain. What do you use?
- A scheduled Lambda that scans and deletes
- DynamoDB TTL on an expiry timestamp attribute
- DynamoDB Streams
- A shorter backup retention
👉 Click to reveal the answer & explanation
Correct answer: B. DynamoDB TTL auto-deletes items past their expiry timestamp at no extra cost and no code. A scheduled scan-and-delete (A) is costly and complex; Streams (C) capture changes, they don’t expire items; backup retention (D) is unrelated.
Related topics
Amazon DynamoDB · DynamoDB Streams · DynamoDB capacity modes
Ready to pass the AWS Data Engineer Associate (DEA-C01)?
Stop guessing whether you’re ready. Our full-length, exam-realistic practice exams put you through the exact question style you’ll face — with a detailed explanation behind every answer, so you learn why, not just what.
- ✓ 6 full-length practice exams
- ✓ A detailed explanation for every single question
- ✓ Realistic, scenario-based questions — not memory dumps
- ✓ 6 months of access to your selected certification pack
Get the DEA-C01 Practice Exams →or try 25 free questions first