Building a Reusable Terraform Static Site Module with CloudFront, S3, and Route 53
Overview
A common need in modern cloud infrastructure is hosting static websites — whether it's marketing sites, documentation portals, or Single Page Applications (SPAs) built with React, Vue, or Svelte.
At first, the AWS building blocks for this are fairly simple:
- S3 for object storage
- CloudFront for CDN
- ACM for HTTPS
- Route 53 for DNS
But quickly, managing this setup by hand or duplicating configs across environments (prod, staging, QA) becomes painful:
- Too many copy/paste Terraform files
- Hard to apply consistent policies
- Complicated to manage uploads (especially when some sites are CI/CD and some are manual content sites)