An application uses an Amazon SQS queue to receive transaction records. A developer is designing an AWS Lambda function to process these transactions. The Lambda function should only be invoked for messages where the `transactionType` is `refund` and the `amount` is greater than . The developer wants to minimize Lambda invocation costs. Which of the following steps should the developer take to meet these requirements? (Select two.)
- Configure an event source mapping between the SQS queue and the Lambda function.Answer
- Specify a FilterCriteria pattern of `{"body": {"transactionType": ["refund"], "amount": [{"numeric": [">", 1000]}]}}` in the event source mapping.Answer
- CWrite custom conditional logic in the Lambda function code to parse the SQS records and exit early if the criteria are not met.
- DSet the SQS queue's visibility timeout to be shorter than the Lambda function's timeout to automatically discard unqualified messages.
- EAdd a Condition block to the SQS queue access policy to deny SendMessage actions for transactions that do not match the criteria.
Answer
Configure an event source mapping between the SQS queue and the Lambda function, and specify a FilterCriteria pattern of `{"body": {"transactionType": ["refund"], "amount": [{"numeric": [">", 1000]}]}}` in the event source mapping.
The correct options are configuring the event source mapping and applying the filter pattern directly to the JSON message body. By defining a filter pattern in the event source mapping, the Lambda service automatically filters out messages where the transaction type is not a refund or the amount is or less. This ensures the Lambda function is only invoked for matching messages, minimizing invocation costs.
Step-by-Step Solution
Key Concept
AWS Lambda Event Source Filtering with Amazon SQS allows filtering of message payloads before invoking the function, reducing cost and processing overhead.
Estimated Time:2m 0s