This lambda function allows to process uploaded user avatars and genereate resized and optimizes squared avatars
This code is one block of a serverless architecture on AWS for image preprocessing. Everytime an image is upload in a given folder on S3, this lambda function will generated the processed version and will save it into another folder on S3
The complete architecture is as follows:
- An S3 folder configured with an Event (Object Create ALL)
- An SNS Topic on which the triggered S3 events is published
- A Lambda function (this) subscribed to the sns topic, in charge of processing the new image that generated the event, and uploading the generated image to S3
The complete process will be:
- A new image is uploaded to the configured folder on S3
- S3 publishes a notification on the configured SNS Topic telling about the new file
- This lambda function, subscribed to the SNS Topic takes the new uploaded images, processes it and uploads it again on s3
A complete description and step-by-step tutorial of the AWS architecture setup can be found here: https://medium.freecodecamp.org/serverless-image-preprocessing-using-aws-lambda-42d58e1183f5