AWS Certified Developer – Associate / Question #955 of 557

Question #955

A company that operates a large logistics platform uses an Amazon DynamoDB table to track order data. The company enabled Amazon DynamoDB Streams on the table. The status of each order is stored in an OrderStatus attribute, which can be delayed, shipped, or delivered. The company wants to be notified of delayed orders where the Weight attribute exceeds a specific threshold. A developer must implement a solution to trigger these notifications with minimal development effort. Which approach meets these requirements?

A

Create an event source mapping between DynamoDB Streams and an AWS Lambda function. Use Lambda event filtering to trigger the Lambda function only when OrderStatus is 'delayed' and Weight exceeds the threshold. Configure the Lambda function to send notifications via an Amazon SNS topic.

B

Create an event source mapping between DynamoDB Streams and an AWS Lambda function. Implement logic in the Lambda handler to check if OrderStatus is 'delayed' and Weight exceeds the threshold, then publish to an Amazon SNS topic.

C

Create an Amazon CloudWatch alarm to monitor DynamoDB Streams for delayed orders. Configure the alarm to trigger an Amazon SNS topic when the Weight attribute exceeds the specified threshold.

D

Create an event source mapping between DynamoDB Streams and an Amazon SNS topic. Use event filtering to publish notifications only for delayed orders where Weight exceeds the threshold.

Explanation

Answer A is correct because:
1. Lambda Event Filtering: Filters events at the event source (DynamoDB Streams), ensuring the Lambda function is invoked only when OrderStatus='delayed' and Weight exceeds the threshold. This reduces Lambda invocations and code complexity.
2. Minimal Development Effort: No need to implement filtering logic in the Lambda code; AWS handles filtering.
3. SNS Integration: Lambda directly sends notifications via SNS.

Why other options are incorrect:
- B: Lambda would process all DynamoDB Stream events, increasing costs and requiring custom filtering code.
- C: CloudWatch cannot monitor DynamoDB Streams for specific item attributes like OrderStatus or Weight; it tracks metrics, not data content.
- D: DynamoDB Streams cannot map directly to SNS; event source mappings require Lambda or Kinesis.

Key Points: Use Lambda event filtering with DynamoDB Streams to reduce costs and simplify logic. Avoid unnecessary Lambda invocations by filtering at the source.

Answer

The correct answer is: A