SAA-C03 Practice Question 99: DynamoDB TTL Expire Items
AWS Certified Solutions Architect – Associate (SAA-C03) · Test 10 · question 9 of 10
A DynamoDB table stores user session records that are useless after 30 days. A scheduled job currently scans the table each night and deletes the old items, and it consumes a large amount of write capacity and has to be maintained. The company wants to remove expired items automatically at the lowest cost and with the least operational effort.
What should the architect do?
Show answer and explanation
Answer:
DynamoDB Time to Live deletes items automatically after the time stored in a designated attribute, which holds a Unix epoch timestamp in seconds. The deletions run in the background and do not consume write capacity, so they add no cost, and there is no job to run or maintain. Adding the expiration attribute (creation time plus 30 days) and enabling TTL replaces the whole scan-and- delete process.
Option A keeps the same design, with the same problem: every delete is a write that consumes capacity, the scan still reads the table, and the Lambda function is still code to maintain.
Option C does not fit the need. A stream emits change events when items are written, updated or deleted, and it never fires because an item has become old. Deleting through stream processing would also consume write capacity.
Option D can work, but it requires custom application logic to route reads and writes between tables plus a job to create and drop them, which is far more effort than a built-in feature.
Reference: Expiring items by using DynamoDB Time to Live (TTL)