Image Resizing Lambdas
Tech Stack
Back End: AWS Lambda, AWS CloudFront, AWS S3, AWS API Gateway, NodeJS, Amazon Route 53, Javascript, Terraform
Issues Fixed
1. Clients were uploading large picture, and they had been uploading large picture for the past 10 years. We needed a way to resize the images on the fly and save the already sized image.
Architecture
Request 1: client makes a request to an S3 bucket with a prefix "/images/300x300/"aws_storage_key
Request 2: how the images in that size doesn't exists it will return a redirect to API Gateway with a parameter key="images/300x300/aws_storage_key"
Request 3: app follows the redirect to API Gateway
Request 4: API Gateway executes the AWS Lambda function
Request 5: AWS Lambda checks and validate the parameter and checks if aws_storage_key exists, if something goes wrong it will return a 403 forbidden if anything saving the new file fails i return the original one.
Request 6: Response with a redirect to the newly resized image
Request 7: find the file in aws s3 and return the source.
Terraform
Builded a terraform script to generate and allocate the services in AWS in any number of environments.