Code Architecture

Reading Time 5 mins

Updated on Wed, 4 Mar 2026

Related Content

Deploy Your First Website on AWS Using S3 and CloudFront (Beginner Tutorial)

Deploying your first website feels scary—especially on AWS. But here’s the truth 👇 Hosting a static website on AWS using S3 and CloudFront is one of the easiest, cheapest, and most production-ready ways to go live.

In this beginner tutorial, you’ll learn:

  • What S3 and CloudFront actually do

  • How to host a website on AWS step by step

  • How CloudFront makes your site fast globally

  • Common beginner mistakes (so you don’t repeat them)

By the end, your website will be: ✅ Live ✅ Globally accessible ✅ Secure ✅ Scalable

What We Are Building (Simple Overview)

Flow:

Loading...

What Is Amazon S3?

Amazon S3 (Simple Storage Service) is used to store files like:

  • HTML

  • CSS

  • JavaScript

  • Images

Think of S3 as a cloud folder that can host your website files.

Why S3 for Beginners?

  • Extremely cheap

  • No servers to manage

  • Highly reliable (99.999999999% durability)

What Is Amazon CloudFront?

Amazon CloudFront is a Content Delivery Network (CDN).

It:

  • Caches your website globally

  • Makes your site load faster

  • Adds security (HTTPS)

  • Sits between users and S3

👉 Never expose S3 directly in production. CloudFront is best practice.

Step 1: Create a Simple Website

Create a folder on your laptop:

Loading...

index.html

Loading...

style.css

Loading...

Step 2: Create an S3 Bucket

Steps:

  1. Go to AWS Console → S3

  2. Click Create bucket

  3. Bucket name:

  4. Region: choose nearest region

  5. Uncheck “Block all public access”

  6. Create bucket

Step 3: Upload Website Files to S3

  1. Open your bucket

  2. Click Upload

  3. Upload

  4. Click Upload

Step 4: Enable Static Website Hosting (Optional but Important)

  1. Go to Bucket → Properties

  2. Scroll to Static website hosting

  3. Enable it

  4. Index document:

This gives you a temporary website URL, but we won’t use it in production.

Step 5: Create a CloudFront Distribution

Steps:

  1. Go to CloudFront

  2. Click Create distribution

  3. Origin domain:

  4. Origin access:

  5. Viewer protocol:

  6. Default root object:

  7. Create distribution

⏳ CloudFront takes 10–20 minutes to deploy.

Step 6: Restrict S3 Access (Security Best Practice)

Make sure:

  • S3 bucket is not public

  • Only CloudFront can access it

CloudFront OAC automatically helps with this.

Step 7: Access Your Live Website 🎉

Once CloudFront finishes deploying:

You’ll get a URL like:

Loading...

Open it in your browser - your website is LIVE!

Cost Breakdown (Very Cheap)

ServiceCost
S3 Storage~$0.02/GB
CloudFrontFree tier available
SSLFree

💡 Many personal sites run under ₹50/month.

Common Beginner Mistakes (Avoid These!)

  • Forgetting index.html as root object

  • Making S3 public unnecessarily

  • Skipping CloudFront

  • Not redirecting HTTP → HTTPS

  • Uploading backend code to S3

When Should You Use This Setup?

Perfect for:

  • Portfolio websites

  • Landing pages

  • Blogs

  • Documentation sites

  • React build output

Not suitable for:

  • Backend APIs

  • Authentication servers

  • Dynamic server-side logic

How This Helps in Interviews & Freelancing

Interviewers love hearing:

“I deployed my site using S3 + CloudFront with HTTPS and CDN caching.”

It shows:

  • Cloud knowledge

  • Security awareness

  • Production mindset

Final Thoughts

If you’re new to AWS, this is the best possible first deployment.

You learned: ✅ Cloud fundamentals ✅ CDN concepts ✅ Secure hosting ✅ Real production practices

From here, you can easily move to:

  • Custom domains

  • React / Next.js deployments

  • Full-stack AWS architecture