AWS Certified Developer – Associate — Question 174
A developer is building a new application that uses an Amazon DynamoDB table. The specification states that all items that are older than 48 hours must be removed.
Which solution will meet this requirement?
Answer options
- A. Create a new attribute that has the Number data type. Add a local secondary index (LSI) for this attribute, and enable TTL with an expiration of 48 hours. In the application code, set the value of this attribute to the current timestamp for each new item that is being inserted.
- B. Create a new attribute that has the String data type. Add a local secondary index (LSI) for this attribute, and enable TTL with an expiration of 48 hours. In the application code, set the value of this attribute to the current timestamp for each new item that is being inserted.
- C. Create a new attribute that has the Number data type. Enable TTL on the DynamoDB table for this attribute. In the application code, set the value of this attribute to the current timestamp plus 48 hours for each new item that is being inserted.
- D. Create a new attribute that has the String data type. Enable TTL on the DynamoDB table for this attribute. In the application code, set the value of this attribute to the current timestamp plus 48 hours for each new item that is being inserted.
Correct answer: C
Explanation
The correct answer is C because it correctly enables TTL on a Number data type attribute and sets the timestamp for expiration as the current timestamp plus 48 hours. Options A and B incorrectly involve using a local secondary index, which is not necessary for TTL, while D uses a String data type, which is not suitable for TTL expiration timestamps.