Question #570
A company processes payment transactions from multiple vendors through an API Gateway integrated with AWS Lambda. Each vendor submits transactions via a dedicated API. The Lambda function processes these transactions. Vendors must receive confirmation messages only for their transactions, and adding new vendors should require minimal code changes. What is the MOST scalable solution?
Create a separate Amazon SNS topic for each vendor. Configure the Lambda function to publish confirmations for each vendor to their respective SNS topic.
Create a separate Lambda function for each vendor. Configure each function to send confirmations directly to the vendor's service endpoint.
Create a single Amazon SNS topic. Configure the Lambda function to publish messages with vendor-specific attributes to the topic. Subscribe each vendor to the topic and apply filter policies to their subscriptions.
Create one Amazon SNS topic. Subscribe all vendors to the topic without any filtering.
Explanation
Option C is correct because:
1. Scalability: A single SNS topic simplifies infrastructure management. Adding new vendors only requires creating a subscription with a filter policy, avoiding code changes.
2. Filtering: SNS subscription filter policies ensure vendors receive only their transaction confirmations by filtering messages based on attributes (e.g., vendor ID).
3. Minimal Code Changes: The Lambda function publishes messages with vendor-specific attributes once, eliminating the need to modify code for new vendors.
Other options are incorrect because:
- A: Managing separate SNS topics per vendor is complex and requires code updates for each new vendor.
- B: Separate Lambda functions per vendor increase operational overhead and code changes.
- D: No filtering would send all confirmations to all vendors, violating requirements.
Key Points: Use SNS filtering for message routing, minimize code changes via attribute-based publishing, and centralize infrastructure for scalability.
Answer
The correct answer is: C