A developer is implementing an IoT application using DynamoDB as the data store for device event data.An application requirement is to purge all event data older than 30 days automatically.What is the optimal option to implement this requirement?
Click on the arrows to vote for the correct answerA. B. C. D.
Option A is CORRECT because Time to Live (TTL) for Amazon DynamoDB is functionality that enables automatic deletion of items after a specified expiration time defined by a timestamp in the TTL attribute.
Option B is incorrect because this is not the optimal solution as it requires implementation and deployment for custom code inside a Lambda function.
Option C is incorrect because it would delete items newer than 30 days.
Option D is incorrect because this does not satisfy the original requirement.It would not purge data in the table.
Sure, I'll provide a detailed explanation of each option to help you understand the pros and cons of each approach.
Option A: Enable TTL on the DynamoDB table and store the expiration timestamp in the TTL attribute in the epoch time format.
TTL (Time To Live) is a feature in DynamoDB that automatically deletes expired items from the table. When you enable TTL on a DynamoDB table, you can specify an attribute name that contains the expiration time for each item. DynamoDB checks this attribute against the current time and automatically deletes items that have expired.
In this option, you would enable TTL on the DynamoDB table and store the expiration timestamp in the TTL attribute in the epoch time format. You could use a Lambda function to write the current time plus 30 days to the TTL attribute when inserting new items into the table. DynamoDB would automatically delete expired items when their TTL attribute matches or exceeds the current time.
Option B: Implement a Lambda function to perform a query and delete on the table for items with a timestamp greater than 30 days. Use CloudWatch events to trigger the Lambda function.
In this option, you would write a Lambda function to query the DynamoDB table for items with a timestamp greater than 30 days. The Lambda function would then delete these items from the table. You would use CloudWatch events to trigger the Lambda function on a regular schedule.
Option C: Create a new DynamoDB table every 30 days. Delete the old DynamoDB table.
In this option, you would create a new DynamoDB table every 30 days and copy the data from the old table to the new table. You would then delete the old table to purge old data.
Option D: Enable DynamoDB streams on the table. Implement a Lambda function to read events from the stream and delete expired items.
DynamoDB streams capture a time-ordered sequence of item-level modifications in a DynamoDB table. In this option, you would enable DynamoDB streams on the table and write a Lambda function to read events from the stream. The Lambda function would delete expired items based on their timestamp.