Menu

1 / 2

Deploy React (Vite) to AWS the Right Way — S3 + CloudFront + CodePipeline

DEV Community·Rajaram Yadav·7 months ago
#hH58YSkt
#aws#react#devops#frontend#cloudfront
Reading 0:00
15s threshold

Stop paying for nginx containers to serve static files. Here's the complete S3 + CloudFront setup with automated CI/CD — costs under $2/month.

Your React app is a collection of static files after npm run build. HTML. JavaScript. CSS. Images.

Serving static files from a Docker container on ECS is paying a chef to microwave leftovers. S3 + CloudFront costs less than a coffee per month, serves files from 400+ global edge locations, and scales to millions of requests automatically.

Here's the complete setup — S3 bucket, CloudFront distribution, CodePipeline CI/CD — so every push to main automatically builds and deploys your Vite app in under 3 minutes.

Why Not a Container?

ECS + nginx container:

EC2 instance : ~$15/month

ALB (for HTTPS) : ~$16/month

Total : ~$31/month

Regions served : 1

S3 + CloudFront:

S3 storage : ~$0.12/month

CloudFront : ~$0.88/month

Total : ~$1/month

Regions served : 400+ edge locations worldwide

The only case for containerising React: you're using Next.js with server-side…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.