Q34 — AWS DVA-C02 Ch.2
Question 34 of 100 | ← Chapter 2
A developer is building a new application that uses an Amazon DynamoDB table. The specification requires deletion of all items older than 48 hours. Which solution meets this requirement?
- A. Create a new attribute with numeric data type. Add a Local Secondary Index (LSI) on this attribute and enable TTL with a 48-hour expiration. In application code, set this attribute’s value to the current timestamp for each newly inserted item.
- B. Create a new attribute with string data type. Add a Local Secondary Index (LSI) on this attribute and enable TTL with a 48-hour expiration. In application code, set this attribute’s value to the current timestamp for each newly inserted item.
- C. Create a new attribute with numeric data type. Enable TTL on the DynamoDB table for this attribute. In application code, set this attribute’s value to the current timestamp plus 48 hours for each newly inserted item. ✓
- D. Create a new attribute with string data type. Enable TTL on the DynamoDB table for this attribute. In application code, set this attribute’s value to the current timestamp plus 48 hours for each newly inserted item.
Correct Answer: C. Create a new attribute with numeric data type. Enable TTL on the DynamoDB table for this attribute. In application code, set this attribute’s value to the current timestamp plus 48 hours for each newly inserted item.
Explanation
In Amazon DynamoDB, TTL must be enabled at the table level—not on a Local Secondary Index—and requires a numeric attribute representing epoch time in seconds. To expire items after 48 hours, the application must set the TTL attribute to the current Unix timestamp plus 48 hours (in seconds). Options A and B incorrectly attempt to enable TTL on an LSI, which is unsupported. Option D uses a string data type, which is invalid for TTL. Only Option C correctly configures TTL at the table level with a numeric attribute and proper timestamp calculation.