DEV Community

Alex Aslam
Alex Aslam

Posted on

Blazing-Fast Static Sites on AWS: S3 + CloudFront in 5 Minutes 🚀

The Problem: "Why Is My Static Site So Slow?"

You built a sleek React/Vue/HTML site—but hosting it on a $5 VPS feels like delivering a Ferrari on a bicycle. Slow loads. Patchy uptime. And don’t get me started on HTTPS setup headaches.

Good news: AWS S3 + CloudFront gives you:

Global speed (CDN-powered)

Zero servers (no SSH, no patches)

Free HTTPS (automated certificates)

Costs pennies (seriously, ~$0.50/month)

Let’s deploy like a pro.


Step 1: Dump Your Files in S3 (The "Dumb" Bucket) 🪣

S3 is just a file dump—but perfect for static sites.

1. Create a Bucket

  • Go to AWS S3 ConsoleCreate bucket
  • Name: yourdomain.com (must match your domain)
  • Disable "Block all public access" (⚠️ then confirm)

2. Upload Files

Drag and drop your:

  • index.html
  • styles.css
  • app.js
  • /assets folder

3. Enable Static Hosting

  • Go to PropertiesStatic website hosting
  • Select "Enable"
  • Set index.html as default

💡 Pro Tip: Use the S3 website URL to test (http://your-bucket.s3-website-us-east-1.amazonaws.com).


Step 2: Add CloudFront (The Speed Booster) ⚡

S3 alone is slow outside AWS regions. CloudFront (AWS’s CDN) fixes this.

1. Create a CloudFront Distribution

  • Go to CloudFront ConsoleCreate distribution
  • Origin domain: Select your S3 bucket (your-bucket.s3.amazonaws.com)
  • Viewer protocol policy: Redirect HTTP to HTTPS
  • Alternate domain name: www.yourdomain.com (optional)

2. Set Up HTTPS (Free!)

  • Click "Request certificate" (if using a custom domain)
  • Validate via DNS (add a CNAME record)

🚀 Boom! Your site is now:

  • Globally fast (290+ edge locations)
  • HTTPS-secured (Auto-renewing certs)
  • DDoS-protected (AWS Shield Standard)

Step 3: Point Your Domain (Optional) 🌐

Want yourdomain.com instead of d123.cloudfront.net?

1. Route 53 (AWS DNS)

  • Create a hosted zone for yourdomain.com
  • Add an A record pointing to your CloudFront distribution

2. External DNS (GoDaddy, Cloudflare, etc.)

  • Add a CNAME record:
  Name: www  
  Value: d123.cloudfront.net  
Enter fullscreen mode Exit fullscreen mode

Real-World Performance & Cost

Metric S3 + CloudFront Traditional VPS
Load Time (NY→Tokyo) 200ms 2s+
Uptime 99.99% 99.9%
Monthly Cost $0.50 (10k visits) $5+

When Not to Use S3 + CloudFront

  • Dynamic sites (Node.js/PHP backends → use EC2/Elastic Beanstalk).
  • User uploads (S3 is read-optimized; consider AWS Lambda for processing).

Final Checklist ✅

  1. ☑️ S3 bucket = public + static hosting enabled
  2. ☑️ CloudFront distribution = HTTPS + caching
  3. ☑️ Domain pointed (Route 53 or external DNS)

Your move:

  1. Migrate one static site today (portfolio, docs, blog).
  2. Never stress about scaling again.

Tag a dev still paying for shared hosting—they deserve better! 🚀

🔗 Need help?

💬 Tried this? Share your results below!

Top comments (0)