The Serverless Image Resizer is an event-driven cloud application that automatically resizes images when they are uploaded. It uses AWS serverless services to process and deliver optimized images without managing any servers.
When a user uploads an image, it is automatically resized and stored in a separate bucket. The processed image is then served globally using a CDN for fast access.
- Automatic image resizing on upload
- Fully serverless architecture
- Scalable and cost-efficient (AWS Free Tier compatible)
- Global image delivery using CDN
- No manual processing required
- Amazon S3 β Storage for input and output images
- AWS Lambda β Serverless compute for resizing images
- Pillow (Python Library) β Image processing
- Amazon CloudFront β Content Delivery Network (CDN)
- IAM Roles β Secure permissions management
-
User uploads an image to the S3 Input Bucket
-
S3 triggers a Lambda function
-
Lambda:
- Downloads the image
- Resizes it (e.g., 300x300)
- Optimizes the format
-
Resized image is saved to S3 Output Bucket
-
CloudFront serves the image globally
- Input bucket
- Output bucket
- Runtime: Python 3.10
- Add IAM Role with S3 access
(CloudShell method)
- Origin: Output bucket
- Enable OAC
AWS Lambda provides a minimal runtime environment and does not include image processing libraries like Pillow by default.
Since this project requires:
- Image resizing
- Image format conversion
- Image optimization
π We must include an external library (Pillow).
- Keeps Lambda deployment package small
- Reusable across multiple functions
- Cleaner architecture
- Follows AWS best practices
Pillow contains compiled components (_imaging) which must match:
- Linux environment (Amazon Linux)
- Correct Python runtime (3.10 in this project)
π Thatβs why we use CloudShell to build the layer.
Go to AWS Console β Click CloudShell (>_)
# Clean setup
rm -rf pillow-layer
mkdir pillow-layer
cd pillow-layer
mkdir python
# Install Pillow compatible with Lambda (Python 3.10)
pip3 install pillow --platform manylinux2014_x86_64 \
--target=python/ \
--implementation cp \
--python-version 3.10 \
--only-binary=:all: \
--upgrade
# Zip the layer
zip -r pillow-layer.zip python- Click Actions β Download file
- Enter:
pillow-layer.zip- Go to Lambda β Layers β Create layer
- Name:
pillow-layer - Upload:
pillow-layer.zip - Runtime: Python 3.10
- Create
- Open Lambda function
- Scroll β Layers
- Remove old layer (if any)
- Add
pillow-layer
Stack_Output.png (79.3 KB)
resized-Stack_Output.png (10.8 KB)
π Significant size reduction improves performance.
https://<your-cloudfront-domain>/resized-image.png
- S3 buckets are not public
- Access is restricted via CloudFront Origin Access Control (OAC)
- IAM roles follow least privilege principle
- Social media apps (profile pictures)
- E-commerce platforms (product thumbnails)
- Portfolio websites (image optimization)
- Blogging platforms (faster load times)
- No server management
- Automatically scales with usage
- Low cost (pay-per-use)
- Faster content delivery worldwide
- Multiple image sizes (thumbnail, medium, large)
- Convert images to WebP format
- Add watermarking
- API-based upload using API Gateway
- Frontend UI for uploading images
- Logging and monitoring with CloudWatch
- Understanding of serverless architecture
- Hands-on experience with AWS services
- Event-driven system design
- CDN integration for performance optimization
This project demonstrates how modern cloud applications can be built using serverless technologies. It showcases scalability, automation, and performance optimization using AWS services.
Jai Dev B.Tech CSE | Cloud Computing Enthusiast | Cloud Engineering | DevOps
