Resizing images uploaded to Amazon S3 with AWS Lambda (Java)

Amazon S3 → AWS Lambda → Amazon S3

Create an AWS Lambda function that resizes images uploaded to Amazon S3.

This sample project shows how to use a Java-based Lambda function to resize an image from a source S3 bucket and put the resized image in a destination S3 bucket.
When a new JPEG image is added to the source S3 bucket, an event gets triggered which invoks the Java-based Lambda function. The Lambda functions gets the object from the bucket, resizes it to 800x600 resolution, and puts the resized image in the destination bucket.
This pattern uses AWS SAM with Lambda SnapStart on ARM64 architecture on a Java 21 manged runtime.

< Back to all patterns
AWS Top Pick

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/s3-lambda-resizing-java

Deploy

sam build && sam deploy --guided


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

Delete the stack: sam delete.

Created by:

Dhiraj Mahapatro

Dhiraj Mahapatro

Principal Specialist SA, Serverless, AWS.

Follow on LinkedIn