🎯 Goal: Deploy a secure, fast, globally cached static site β€” no console clicks, no hardcoded IDs.

βœ… You’ll build:


🧠 Why This Architecture? (The Right Way)

Approach Risk Cost Performance Security
❌ Public S3 (s3-website-us-east-1.amazonaws.com) DDoS, data leaks High (global data transfer) Slow (no caching) ❌ Open to internet
βœ… S3 + CloudFront (Terraform) None Low (edge caching) ⚑ Fast (TTL, edge POPs) βœ… Private bucket + OAC

πŸ”‘ Key Insight:

CloudFront β‰  CDN β€” it’s your security control plane:


πŸ“¦ Architecture Diagram

flowchart LR
  A[User in India] -->|HTTPS| B[CloudFront Edge: Mumbai]
  C[User in US] -->|HTTPS| D[CloudFront Edge: Virginia]
  B -->|Cache HIT| A
  B -->|Cache MISS| E[S3 Bucket<br/>(private, us-east-1)]
  D -->|Cache HIT| C
  D -->|Cache MISS| E
  E -.->|OAC Auth| B & D

βœ… Critical Components:


✏️ Hands-On: Terraform Implementation

πŸ”Ή File Structure (/day14/)

day14/
β”œβ”€β”€ main.tf           # S3 + CloudFront resources
β”œβ”€β”€ locals.tf         # Reusable values (origin_id)
β”œβ”€β”€ variables.tf      # Inputs (bucket_name, environment)
β”œβ”€β”€ www/              # πŸ“ Your static files
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ style.css
β”‚   └── script.js
└── TASK.md           # πŸ“ Your challenge (ACM, Route 53, CI/CD)


1️⃣ main.tf β€” Core Resources