Which solution meets these requirements?
Use an AWS CloudFormation template to deploy the complete solution. Redeploy the CloudFormation stack every 30 days, and delete the original stack.
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.
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.
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.
Explanations:
Redeploying the CloudFormation stack every 30 days is inefficient and does not effectively manage data retention. It also requires significant manual intervention and does not address the data deletion directly.
While using an EC2 instance and monitoring application could technically work, it adds unnecessary complexity, requires maintenance, and incurs ongoing costs for the instance. Additionally, it does not leverage DynamoDB’s built-in features for automatic data management.
This option uses DynamoDB Streams to trigger a Lambda function for deletions, which is a valid approach, but it involves maintaining additional resources and processing logic that could complicate the architecture unnecessarily.
Using TTL (Time to Live) is a built-in feature of DynamoDB that allows automatic deletion of items after a specified time, which simplifies the solution and minimizes costs. It requires minimal development effort and aligns well with the requirement to only keep data for the last 30 days.