DEV Community

Cloudev
Cloudev

Posted on

Building a Serverless Image Resizer on AWS

AWS Serverless means building and running applications without managing servers. You don’t need to provision, scale, or maintain infrastructure. AWS handles that automatically while you focus on writing code and designing logic.

Resizing images is a common task, but managing servers to do it can be complex and expensive. With AWS serverless services, you can process images automatically without worrying about servers, scaling, or uptime.

I built a Serverless Image Resizer using AWS Lambda, S3, and SAM. It automatically resizes any image uploaded to an S3 bucket and saves the resized version to another bucket.

What the Project Does

When you upload an image to a source S3 bucket:

  1. It triggers a Lambda function.

  2. The Lambda downloads the image, resizes it to 300x300 pixels, and keeps the aspect ratio.

  3. The resized image is uploaded to a destination S3 bucket.

The function supports JPEG, PNG, GIF, BMP, and TIFF image formats.

Why I Used Serverless

Serverless architecture is simple, cost-effective, and fully managed by AWS.
You don’t maintain any servers. AWS handles scaling, availability, and security patches automatically. You only pay when your Lambda function runs.

This approach makes it ideal for image processing workloads that don’t run continuously.

Tools and Technologies

  1. AWS Lambda – runs the image resize code

  2. Amazon S3 – stores source and resized images

  3. AWS SAM – builds and deploys the application

  4. Python (Pillow) – processes and resizes images

  5. Amazon CloudWatch – monitors performance

  6. SQS (DLQ) – stores failed image events

  7. DynamoDB (optional) – stores metadata

How to Deploy

You can deploy it using AWS SAM:

1.Clone the repo

git clone https://github.com/Copubah/serverless-image-resizer.git
cd serverless-image-resizer

Enter fullscreen mode Exit fullscreen mode
  1. Build the app
make build

Enter fullscreen mode Exit fullscreen mode
  1. Deploy it
make deploy-guided

Enter fullscreen mode Exit fullscreen mode

4.Upload a test image

make test-upload

Enter fullscreen mode Exit fullscreen mode

After upload, the resized image appears in the destination bucket.

Monitoring and Reliability

The project includes:

  • CloudWatch alarms for errors and latency.

  • Dead Letter Queue (DLQ) for failed image events.

  • Encrypted S3 buckets and least privilege IAM roles for better security

You can find the full source code and setup guide here:
https://github.com/Copubah/serverless-image-resizer

Top comments (0)