πŸ”— Repo: github.com/Push/terraform-aws-labs/day18

🎯 Goal: Build a fully automated image pipeline β€” upload β†’ process β†’ 5 variants β€” zero servers, zero manual steps.

βœ… You’ll build:


🧠 Why Serverless? (The β€œIt Works on My Machine” Fix)

Traditional EC2 Serverless Lambda
❌ Servers run 24/7 β†’ pay even when idle βœ… Pay per millisecond of execution
❌ Manual scaling (ASG configs, ALB rules) βœ… Auto-scales to 1,000+ concurrent invocations
❌ OS patching, security updates βœ… AWS manages OS/runtime
❌ β€œIt works on my Mac” β†’ breaks in prod βœ… βœ… Docker-based layer builds (Day 18’s key fix!)

πŸ’‘ Golden Rule:

β€œIf your workload is event-driven and <15 mins β€” Lambda is your friend.”


πŸ“¦ Architecture Diagram

flowchart LR
  A[Upload Image<br/>to S3] -->|s3:ObjectCreated:*| B[Lambda Trigger]
  B --> C[Lambda Function<br/>(Python + Pillow)]
  C --> D1[Compressed JPEG<br/>(85% quality)]
  C --> D2[Low-Quality JPEG<br/>(60% quality)]
  C --> D3[WebP<br/>(85% quality)]
  C --> D4[PNG<br/>(lossless)]
  C --> D5[Thumbnail<br/>(200x200)]
  D1 --> E[Processed S3 Bucket]
  D2 --> E
  D3 --> E
  D4 --> E
  D5 --> E
  C --> F[CloudWatch Logs]

βœ… Critical Flow:

  1. User uploads photo.jpg to upload-bucket-dev

  2. S3 emits s3:ObjectCreated:Put event

  3. Lambda invoked with event payload:

    {"Records": [{"s3": {"bucket": {"name": "upload-bucket-dev"}, "object": {"key": "photo.jpg"}}}]}
    
    
  4. Lambda:

  5. Logs duration/memory to CloudWatch


✏️ Hands-On: Terraform Implementation

πŸ”Ή File Structure (/day18/)