AWS Certified Developer – Associate — Question 284
A company is expanding the compatibility of its photo-sharing mobile app to hundreds of additional devices with unique screen dimensions and resolutions. Photos are stored in Amazon S3 in their original format and resolution. The company uses an Amazon CloudFront distribution to serve the photos. The app includes the dimension and resolution of the display as GET parameters with every request.
A developer needs to implement a solution that optimizes the photos that are served to each device to reduce load time and increase photo quality.
Which solution will meet these requirements MOST cost-effectively?
Answer options
- A. Use S3 Batch Operations to invoke an AWS Lambda function to create new variants of the photos with the required dimensions and resolutions. Create a dynamic CloudFront origin that automatically maps the request of each device to the corresponding photo variant.
- B. Use S3 Batch Operations to invoke an AWS Lambda function to create new variants of the photos with the required dimensions and resolutions. Create a Lambda@Edge function to route requests to the corresponding photo variant by using request headers.
- C. Create a Lambda@Edge function that optimizes the photos upon request and returns the photos as a response. Change the CloudFront TTL cache policy to the maximum value possible.
- D. Create a Lambda@Edge function that optimizes the photos upon request and returns the photos as a response. In the same function, store a copy of the processed photos on Amazon S3 for subsequent requests.
Correct answer: D
Explanation
Using Lambda@Edge to optimize images on-demand is highly cost-effective because it avoids pre-generating hundreds of variations for every image using S3 Batch Operations, which would result in high storage and processing costs. Storing the newly optimized images back in Amazon S3 ensures that future requests for the same dimensions are served directly without invoking the Lambda@Edge processing logic again, minimizing compute costs. This hybrid approach is significantly cheaper than relying purely on CloudFront's cache TTL, which would eventually expire and trigger costly re-processing.