How to automate DynamoDB item expiration and archival with minimal code?
A developer supports an application that accesses data in an Amazon DynamoDB table. One of the item attributes is expirationDate in the timestamp format. The application uses this attribute to find items, archive them, and remove them from the table based on the timestamp value. The application will be decommissioned soon, and the developer must find another way to implement this functionality. The developer needs a solution that will require the least amount of code to write. Which solution will meet these requirements?
Community Votes
100% of anonymous learners picked answer A. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
This question tests the combination of DynamoDB TTL for automatic expiration and DynamoDB Streams to capture the deletion event, eliminating the need for custom scanning and deletion code.
DynamoDB TTL automatically deletes expired items, and when combined with DynamoDB Streams and a Lambda trigger, it provides a code-free expiration mechanism that also captures deleted items for archival processing.
Candidates often choose option C, assuming they must manually scan the table and delete items via Lambda and EventBridge, because they overlook that DynamoDB TTL natively handles expiration without any custom deletion logic.
Community Discussion (5 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Understanding the Requirement
The application currently uses an expirationDate attribute to find, archive, and delete items from a DynamoDB table. The developer needs a replacement that requires the least amount of code. The key operations are:
1. Automatic deletion of items past their expiration date.
2. Archival/processing of those deleted items.
Why Option A is Correct
Option A leverages three native AWS features working together:
- DynamoDB TTL (Time to Live): You enable TTL on the
expirationDateattribute. DynamoDB automatically identifies and deletes items whose timestamp is older than the current time. This requires zero code for the deletion process. - DynamoDB Streams: When TTL deletes an item, the deletion is recorded in the DynamoDB Stream as a
REMOVEevent. - AWS Lambda Trigger: By creating a DynamoDB trigger on the stream, the Lambda function is automatically invoked with the deleted item data, allowing the developer to archive or process the item.
Why the Other Options are Incorrect
- Option B: Requires writing custom Lambda functions to scan the table, evaluate expiration dates, and call
DeleteItem. This is significantly more code and operational overhead than using TTL. - Option C: Similar to B, it relies on an EventBridge rule to invoke Lambda for scanning and deleting. It also incorrectly suggests using
GetRecordsdirectly on the DynamoDB table (Streams are required forGetRecords). This is the most code-heavy approach. - Option D: DynamoDB TTL does not support sending deleted items directly to an SQS dead-letter queue. TTL deletions can only be captured via DynamoDB Streams. This option describes a non-existent feature.
Community Consensus
The community unanimously agrees on Option A (100% vote). Commenters highlight that TTL + Streams + Lambda is the standard, most efficient pattern for this use case, completely eliminating the need for custom deletion logic.
Related Analysis
Practice All DVA-C02 Questions
Access 100 questions with complete answers and detailed explanations.
View Full DVA-C02 Practice Test →