This project implements an event-driven, serverless image processing pipeline on AWS. Images uploaded to Amazon S3 are automatically resized using AWS Lambda and Pillow, stored in a destination bucket, and followed by an email notification using Amazon SNS.
Applications that accept user-uploaded images often need standardized image sizes for thumbnails, profile photos, or product listings. Handling this on traditional servers increases operational overhead and cost.
This project solves the problem using a fully serverless approach:
- Automatic image resizing on upload
- No servers or background workers to manage
- Instant notification once processing is complete
- User uploads an image to an S3 bucket
- S3 triggers an AWS Lambda function
- Lambda resizes the image using Pillow (via a Lambda Layer)
- Resized image is saved to a destination S3 bucket
- Lambda publishes a notification to an SNS topic
This design follows an event-driven, cloud-native architecture.
- AWS S3 – Image storage and event source
- AWS Lambda – Serverless compute
- Python 3.10 / 3.11 – Runtime
- Pillow (PIL) – Image processing
- Lambda Layer – Dependency packaging
- AWS SNS – Email notifications
| Purpose | Bucket Name |
|---|---|
| Input images | image-resize-input45 |
| Resized images | image-resize-result45 |
| Backup originals | image-resize-backup45 |
AWS Lambda does not include Pillow by default. Since Pillow depends on native system libraries, it must be packaged separately.
A Lambda Layer is used to:
- Package Pillow correctly for Amazon Linux
- Keep Lambda function code clean
- Reuse the dependency across functions
Lambda automatically mounts layers at:
/opt/python/Pillow must be built on Amazon Linux. Use AWS CloudShell:
mkdir pillow-layer
cd pillow-layer
mkdir python
pip3 install pillow==10.2.0 -t python/
zip -r pillow-layer.zip python
Upload pillow-layer.zip as a Lambda Layer and attach it to your function.
The Lambda function performs the following steps:
- Reads the uploaded image from S3
- Backs up the original image
- Resizes the image using Pillow
- Saves the resized image to a destination bucket
- Sends a notification using SNS
- Event-driven architecture
- Serverless compute
- In-memory file processing
- Native dependency packaging
- Asynchronous notifications with SNS
| Setting | Recommended Value |
|---|---|
| Runtime | Python 3.10 / 3.11 |
| Memory | 512 MB |
| Timeout | 15 seconds |
The Lambda execution role requires the following permissions:
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject",
"sns:Publish"
],
"Resource": [
"arn:aws:s3:::image-resize-input45/*",
"arn:aws:s3:::image-resize-result45/*",
"arn:aws:s3:::image-resize-backup45/*",
"arn:aws:sns:ap-south-1:ACCOUNT_ID:image-resize-notification"
]
}
- No module named PIL – Pillow layer not attached
- _imaging import error – Layer built for wrong Python version
- Lambda not triggered – S3 event notification missing
- SNS publish denied – Missing
sns:Publishpermission
- User profile photo processing
- E-commerce product image resizing
- CMS image optimization pipelines
- Media processing workflows with alerts
- Multiple output sizes
- Preserve original image format
- Watermarking
- EXIF auto-rotation
- CloudFront CDN integration
This project demonstrates a clean, production-ready approach to serverless image processing on AWS. It combines S3, Lambda, Pillow, and SNS into a scalable, low-maintenance pipeline suitable for real systems.
Built as a learning-focused yet production-aligned implementation.