Q71 — AWS SAP-C02 Ch.1
Question 71 of 75 | ← Chapter 1
Q146. A company's interactive web application uses an Amazon CloudFront distribution to serve images from an Amazon S3 bucket. Occasionally, third-party tools ingest corrupted images into the S3 bucket. This image corruption causes a poor user experience in the application later. The company has successfully implemented and tested Python logic to detect corrupt images.A solutions architect must recommend a solution to integrate the detection logic with minimal latency between the ingestion and serving.Which solution will meet these requirements?
- A. Use a Lambda@Edge function that is invoked by a viewer-response event
- B. Use a Lambda@Edge function that is invoked by an origin-response event
- C. Use an S3 event notification that invokes an AWS Lambda function ✓
- D. Use an S3 event notification that invokes an AWS Step Functions state machine
Correct Answer: C. Use an S3 event notification that invokes an AWS Lambda function
Explanation
The solution that will meet the requirements with minimal latency between ingestion and serving is option C, which is to use an S3 event notification that invokes an AWS Lambda function. When a third-party tool ingests a corrupted image into the S3 bucket, the S3 event notification can trigger the Lambda function immediately. The Lambda function can then run the Python logic to detect the corrupt image. If the image is found to be corrupt, the Lambda function can delete it from the S3 bucket before it gets served through the Amazon CloudFront distribution. This solution ensures that the detection logic is integrated with minimal latency because the Lambda function is triggered as soon as the event (ingestion of an object) occurs in S3. Option A is not suitable because viewer-response events occur after CloudFront has processed the request and returned the response to the viewer. Option B is not ideal because origin-response events occur after Amazon CloudFront receives the response from the origin, which could potentially increase the latency. Option D is not necessary for this scenario because the problem can be solved with a simpler architecture using just S3 and Lambda.