Q50 — AWS DVA-C02 Ch.2
Question 50 of 100 | ← Chapter 2
A developer supports an application that accesses data in an Amazon DynamoDB table. One of the item attributes is expirationDate, formatted as a timestamp. The application uses a scheduled job to scan the table, retrieve items with expired timestamps, and delete them. The application is being deprecated, and the developer must adopt an alternative implementation for this functionality. The developer needs a solution requiring the least amount of custom code. Which solution meets these requirements?
- A. Enable TTL on the expirationDate attribute in the table. Create a DynamoDB stream. Create an AWS Lambda function to process deleted items. Configure a DynamoDB trigger for the Lambda function. ✓
- B. Create two AWS Lambda functions—one to delete items and one to process items. Create a DynamoDB stream. Use the DeleteItem API operation to delete items based on the expirationDate attribute. Use the GetRecords API operation to retrieve items from the DynamoDB stream for processing.
- C. Create two AWS Lambda functions—one to delete items and one to process items. Create an Amazon EventBridge scheduled rule to invoke the Lambda functions. Use the DeleteItem API operation to delete items based on the expirationDate attribute. Use the GetRecords API operation to retrieve items directly from the DynamoDB table for processing.
- D. Enable TTL on the expirationDate attribute in the table. Specify an Amazon Simple Queue Service (Amazon SQS) dead-letter queue as the destination for deleted items. Create an AWS Lambda function to process items.
Correct Answer: A. Enable TTL on the expirationDate attribute in the table. Create a DynamoDB stream. Create an AWS Lambda function to process deleted items. Configure a DynamoDB trigger for the Lambda function.
Explanation
Option A recommends enabling Time-to-Live (TTL) on the expirationDate attribute, which automatically deletes expired items. By creating a DynamoDB stream and an AWS Lambda function to process deleted items—and configuring a DynamoDB trigger to invoke the function—the developer can automatically handle deleted items with minimal custom logic. TTL handles expiration natively, and only one Lambda function is required to process deletions. In contrast, other options involve more manual orchestration and additional code. Thus, Option A is the most code-efficient solution. 【Lantern Certification provided by: swufelp1999】