A company is using Amazon DynamoDB to store session data for a web application. The session data expires after 24 hours. Which DynamoDB feature should the company use to automatically delete expired items?
TTL automatically deletes expired items based on a timestamp attribute.
Why this answer
DynamoDB Time to Live (TTL) is the correct choice because it provides a cost-effective, fully managed mechanism to automatically delete expired items based on a timestamp attribute in the table. TTL works by comparing the current time to the epoch time value stored in the designated TTL attribute; when the value is in the past, DynamoDB marks the item for deletion, typically within 48 hours. This eliminates the need for custom code or additional AWS services, directly addressing the requirement to remove session data after 24 hours.
Exam trap
The trap here is that candidates may overcomplicate the solution by choosing a custom Lambda-based approach (Option D) or misidentifying Streams (Option C) as a deletion mechanism, when DynamoDB's native TTL feature is the simplest, most cost-effective, and fully managed answer.
How to eliminate wrong answers
Option A is wrong because DynamoDB does not support a native 'retention policy' on tables; retention policies are a feature of services like Amazon S3 or CloudWatch Logs, not DynamoDB. Option C is wrong because DynamoDB Streams capture item-level changes (inserts, updates, deletes) in near-real-time but do not themselves delete items; they are a notification mechanism, not a data lifecycle management feature. Option D is wrong because while a scheduled Lambda function that scans and deletes expired items could technically work, it is an inefficient, custom solution that consumes read/write capacity and incurs additional cost and complexity, whereas TTL provides the same functionality natively and at no extra cost.