This is a React + Tailwind CSS + AWS CloudFront + ACM template for deploying static sites with:
- React 19 + TypeScript + Vite (SSR/SSG)
- Tailwind CSS v4
- AWS CloudFront CDN with S3 origin
- ACM SSL certificates with DNS validation
- Route53 DNS management
- Auto-discovered blog system
- Dual-region AWS setup: Primary region for resources, us-east-1 for CloudFront ACM certificates
- Environment strategy:
dev(dev.example.com) andprd(example.com) via Terraform workspaces - S3 buckets: Frontend site (CloudFront OAC) + root redirect (apex -> www)
- CloudFront: URL rewriting function (.html extension), response headers policy for static assets
- Route53: DNS zone created in prd only, shared via SSM parameter with dev
- SSM Parameters: Cross-environment reference for bucket names, distribution IDs, zone IDs
- Modules used: terraform-aws-modules for s3-bucket and cloudfront
- Build pipeline:
vite build(client) ->vite build --ssr(server) ->node scripts/generate-static.js(SSG + sitemap) - Blog auto-discovery: Drop a
.tsxfile insrc/pages/blogs/with exportedmetadataobject -> automatically included in blog index, sitemap, and SSG - Environment-aware: robots.txt (dev=noindex, prd=index), meta tags injected at build time
- Deploy via npm scripts:
npm run publish:devornpm run publish:prd(build -> S3 sync -> CloudFront invalidation)
- Create
ui/src/pages/blogs/my-post-slug.tsx - Export
metadata: BlogMetadatawith title, description, date, slug, author, tags - Export default component with the blog content
- The post is auto-discovered at build time and runtime (via
import.meta.glob)
- Create component in
ui/src/pages/ - Add route in
ui/src/main.tsxandui/src/entry-server.tsx - Add to
staticRoutesandrouteMetainui/scripts/generate-static.js
# Infrastructure (see docs/setup-guide.md for first-time setup)
cd terraform
terraform workspace select prd
terraform apply -var-file=prd.tfvars
# Frontend
cd ui
export SITE_DOMAIN="yourdomain.com"
npm run publish:prd- Copy
terraform/dev.tfvars.example->terraform/dev.tfvarsand fill in your domain - Copy
terraform/prd.tfvars.example->terraform/prd.tfvarsand fill in your domain - Copy
terraform/backend.tf.example->terraform/backend.tfand set your S3 state bucket - Update
ui/src/components/Navbar.tsxwith your site name and nav links - Update
ui/src/components/Footer.tsxwith your site info - Update
ui/src/pages/Home.tsxwith your content - Update
ui/src/pages/Contact.tsxwith your real contact info - Update
ui/index.htmlwith your site title and description - Update
ui/scripts/generate-static.jsCANONICAL_ORIGIN and routeMeta - Update
ui/public/robots.prod.txtwith your sitemap URL
make fmt- Format Terraformmake validate- Validate Terraformmake clean- Clean build artifactsnpm run dev(in ui/) - Local dev servernpm run publish:dev(in ui/) - Build and deploy to devnpm run publish:prd(in ui/) - Build and deploy to prd
├── terraform/ # AWS infrastructure (S3, CloudFront, ACM, Route53)
├── ui/ # React frontend
│ ├── src/
│ │ ├── pages/blogs/ # Auto-discovered blog posts
│ │ ├── components/ # Shared components (Navbar, Footer)
│ │ ├── utils/ # Blog discovery utilities
│ │ └── types/ # TypeScript interfaces
│ └── scripts/ # SSG and sitemap generation
├── docs/ # Setup guide
└── Makefile # Development automation