DOP-C02 Question 274
Single answerAn e-commerce company wants to build a serverless architecture to process customer orders asynchronously. Customer order data is uploaded to an Amazon S3 bucket in JSON format. Upon upload, the company needs to validate the order data using a Lambda function, and if the validation passes, send a notification to a specific Amazon SNS topic for further processing. How should this architecture be implemented using an event-driven design pattern?
- A
Configure an S3 Event Notification to invoke the Lambda function upon object creation, and have the Lambda function publish a message to the SNS topic if the validation is successful.
- B
Configure an Amazon EventBridge rule to monitor the S3 bucket for object creation events and route the events to the Lambda function, which then sends a message to the SNS topic if the validation is successful.
- C
Set up an S3 Event Notification to directly publish to the SNS topic, and configure the SNS topic to invoke a Lambda function to validate the order data.
- D
Use Amazon Kinesis Data Streams to capture S3 object creation events, and configure a Lambda function to process the stream and send notifications to SNS if validation is successful.
Show answer and explanation
Correct answer: A
Explanation
The most efficient way to implement this event-driven, asynchronous architecture is to use Amazon S3 Event Notifications to invoke the Lambda function upon object creation. The Lambda function can then validate the order data and publish a message to the SNS topic if the validation is successful. This approach minimizes complexity and leverages native integrations between S3, Lambda, and SNS.
- A. Correct.
This is the correct option. S3 Event Notifications can directly trigger a Lambda function upon object creation. The Lambda function can then handle the validation logic and publish to SNS if the data is valid.
- B. Incorrect.
This is incorrect. While EventBridge can monitor S3 events, it is not the most straightforward solution for this use case. S3 Event Notifications offer a simpler and more direct way to trigger Lambda functions.
- C. Incorrect.
This is incorrect. S3 Event Notifications cannot directly publish to an SNS topic and trigger a Lambda function sequentially. You would need additional logic to handle the validation step before publishing to SNS.
- D. Incorrect.
This is incorrect. Amazon Kinesis Data Streams is unnecessary for this scenario. S3 Event Notifications provide a simpler and more cost-effective solution for triggering Lambda functions directly.