
Ultimate access to all questions.
Deep dive into the quiz with AI chat providers.
We prepare a focused prompt with your quiz and certificate details so each AI can offer a more tailored, in-depth explanation.
A company runs an application on a large fleet of Amazon EC2 instances. The application reads and writes entries into an Amazon DynamoDB table. The size of the DynamoDB table continuously grows, but the application needs only data from the last 30 days. The company needs a solution that minimizes cost and development effort.
Which solution meets these requirements?
A
Use an AWS CloudFormation template to deploy the complete solution. Redeploy the CloudFormation stack every 30 days, and delete the original stack.
B
Use an EC2 instance that runs a monitoring application from AWS Marketplace. Configure the monitoring application to use Amazon DynamoDB Streams to store the timestamp when a new item is created in the table. Use a script that runs on the EC2 instance to delete items that have a timestamp that is older than 30 days.
C
Configure Amazon DynamoDB Streams to invoke an AWS Lambda function when a new item is created in the table. Configure the Lambda function to delete items in the table that are older than 30 days.
D
Extend the application to add an attribute that has a value of the current timestamp plus 30 days to each new item that is created in the table. Configure DynamoDB to use the attribute as the TTL attribute.
Explanation:
Correct Answer: D
DynamoDB Time to Live (TTL) is the most cost-effective and low-effort solution for automatically deleting old data:
Minimal Development Effort: TTL requires only adding a timestamp attribute to items and enabling TTL on the table. No additional infrastructure or complex code is needed.
Cost-Effective: TTL is a native DynamoDB feature with no additional costs for the deletion process itself. It runs automatically in the background.
Serverless and Managed: No need to manage EC2 instances, Lambda functions, or external monitoring applications.
Automatic Cleanup: DynamoDB automatically deletes expired items based on the TTL attribute, typically within 48 hours of expiration.
Why Other Options Are Incorrect:
A: Redeploying CloudFormation stacks every 30 days would delete the entire table and recreate it, causing data loss and application disruption.
B: Using an EC2 instance with a monitoring application adds unnecessary cost (EC2 instance, Marketplace license) and operational overhead.
C: While Lambda is serverless, this approach requires writing and maintaining custom deletion logic and pays for Lambda execution time, whereas TTL is free and built-in.
Best Practice: When using TTL, ensure the timestamp attribute contains the expiration time (when the item should be deleted), not the creation time. The application should set this to current_time + 30_days for each new item.