Conversion of Images to Web2 in AWS part 2
Table of contents
When converting images to WebP in our cloud, one issue was that it did not effect images that were uploaded before adding the conversion logic. Thus, we needed a way to convert all the images in our S3 bucket.
Problem
S3 contained images that were not in WebP format
Issue
Our team decided to serve all images as WebP to reduce the rendering time on our website.
Solution
Attach a Lambda@Edge to the origin response from our S3 bucket to check if the image was in WebP format. If not, send the data to our Simple Notification Service to which the Lambda in charge of converting the image subscribes.
Implementation
User requests image from CloudFront (CDN)
CloudFront requests image from S3
Lambda@Edge intercepts response and checks whether the image is WebP
If the image is not WebP creates a message to AWS SNS.
Lambda function in charge of converting image to WebP subscribes to the SNS and converts the image.
Subscribe to my newsletter
Read articles from JaeHyun Shim directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by