AWS Certified Database – Specialty — Question 299
A company stores session history for its users in an Amazon DynamoDB table. The company has a large user base and generates large amounts of session data.
Teams analyze the session data for 1 week, and then the data is no longer needed. A database specialist needs to design an automated solution to purge session data that is more than 1 week old.
Which strategy meets these requirements with the MOST operational efficiency?
Answer options
- A. Create an AWS Step Functions state machine with a DynamoDB DeleteItem operation that uses the ConditionExpression parameter to delete items older than a week. Create an Amazon EventBridge (Amazon CloudWatch Events) scheduled rule that runs the Step Functions state machine on a weekly basis.
- B. Create an AWS Lambda function to delete items older than a week from the DynamoDB table. Create an Amazon EventBridge (Amazon CloudWatch Events) scheduled rule that triggers the Lambda function on a weekly basis.
- C. Enable Amazon DynamoDB Streams on the table. Use a stream to invoke an AWS Lambda function to delete items older than a week from the DynamoDB table
- D. Enable TTL on the DynamoDB table and set a Number data type as the TTL attribute. DynamoDB will automatically delete items that have a TTL that is less than the current time.
Correct answer: D
Explanation
Enabling Time to Live (TTL) is the most operationally efficient strategy because DynamoDB automatically identifies and deletes expired items at no additional cost, eliminating the need to write and maintain custom code. Options A, B, and C introduce unnecessary operational overhead and cost by requiring additional AWS services like AWS Lambda, AWS Step Functions, and DynamoDB Streams to manage the deletion process. TTL natively uses a Number data type representing epoch time to automatically handle item expiration.