AWS Certified Developer – Associate (DVA-C02) — Question 374
A developer is creating an AWS Lambda function that is invoked by messages to an Amazon Simple Notification Service (Amazon SNS) topic. The messages represent customer data updates from a customer relationship management (CRM) system
The developer wants the Lambda function to process only the messages that pertain to email address changes. Additional subscribers to the SNS topic will process any other messages.
Which solution will meet these requirements in the LEAST development effort?
Answer options
- A. Use Lambda event filtering to allow only messages that are related to email address changes to invoke the Lambda function.
- B. Use an SNS filter policy on the Lambda function subscription to allow only messages that are related to email address changes to invoke the Lambda function.
- C. Subscribe an Amazon Simple Queue Service (Amazon SQS) queue to the SNS topic. Configure the SQS queue with a filter policy to allow only messages that are related to email address changes. Connect the SQS queue to the Lambda function.
- D. Configure the Lambda code to check the received message. If the message is not related to an email address change, configure the Lambda function to publish the message back to the SNS topic for the other subscribers to process.
Correct answer: B
Explanation
An Amazon SNS subscription filter policy allows a subscriber, such as an AWS Lambda function, to receive only the specific messages that match the defined filter criteria, preventing unnecessary invocations with zero custom code. Option A is incorrect because Lambda event filtering applies to streaming and polling sources like Amazon SQS or Kinesis, not direct SNS push integrations. Options C and D introduce unnecessary complexity, with Option D requiring custom code that could lead to infinite loops and increased execution costs.