Which solution will meet these requirements?
Configure each microservice to create an S3 event notification with its Lambda function as the destination.
Configure AWS CloudTrail event logging for Amazon S3. Create an Amazon EventBridge (Amazon CloudWatch Events) rule with an event pattern that matches PutObject API calls through CloudTrail. Register each microservice’s Lambda function as a target for the rule.
Create an Amazon EventBridge (Amazon CloudWatch Events) rule with an event pattern for PutObject events in S3 event notifications. Configure each microservice to register an Amazon Simple Queue Service (Amazon SQS) queue as a target for the rule. Invoke the microservice’s Lambda function from the SQS queue.
Create an S3 event notification with an Amazon Simple Notification Service (Amazon SNS) topic as the destination. Create an SNS subscription for each microservice’s Lambda function.
Explanations:
While this option sets up individual S3 event notifications for each Lambda function, it can lead to management challenges, as each microservice needs to be configured separately. This approach is less efficient compared to using a single event-driven architecture that can handle multiple targets.
AWS CloudTrail logs API calls but does not directly facilitate immediate processing of uploaded images. This method introduces additional latency because it relies on CloudTrail logs, which may not trigger Lambda functions as quickly as direct S3 events. Additionally, it requires more complex setup and maintenance.
Although this option uses Amazon EventBridge to react to S3 events, it introduces unnecessary complexity by using SQS as an intermediary. The processing of images would be delayed because each image upload would first need to be queued in SQS, adding latency before the Lambda functions can be invoked.
This solution efficiently uses S3 event notifications to send messages to an SNS topic whenever an image is uploaded. Each microservice’s Lambda function can subscribe to the SNS topic, ensuring that all functions are triggered immediately and concurrently without additional overhead. This is a clean, scalable, and real-time solution for processing uploaded images.