DEV Community

Miten M
Miten M

Posted on

🚀 How to Host a Static Website on AWS S3 in 5 Minutes

If you're looking to host a static website (HTML, CSS, JS — no backend logic), Amazon S3 (Simple Storage Service) is a super affordable and reliable solution. In this quick guide, I’ll walk you through the entire process — from creating a bucket to making your site public.


✅ Prerequisites

  • An AWS account
  • Your static site files (HTML, CSS, JS)
  • A domain (optional but recommended)

🪣 Step 1: Create an S3 Bucket

  1. Go to AWS S3 Console
  2. Click “Create bucket”
  3. Enter a globally unique bucket name (e.g., my-portfolio-site)
  4. Choose a region
  5. Uncheck “Block all public access” (you’ll make it public later)
  6. Acknowledge the warning and click Create Bucket

📤 Step 2: Upload Your Website Files

  1. Click on the newly created bucket
  2. Click “Upload”“Add files”
  3. Select all your static files (index.html, styles.css, etc.)
  4. Click “Upload”

🌐 Step 3: Enable Static Website Hosting

  1. Go to the “Properties” tab of the bucket
  2. Scroll to “Static website hosting”
  3. Click “Edit”, select Enable
  4. Set:
  • Index document: index.html
  • (Optional) Error document: error.html
    1. Save changes — you’ll now see a website endpoint URL

🔓 Step 4: Make Your Files Public

By default, objects in S3 are private. To serve your site publicly:

Option A: Set Bucket Policy

  1. Go to Permissions > Bucket policy
  2. Paste the following, replacing your-bucket-name:
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PublicReadGetObject",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::your-bucket-name/*"
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode
  1. Click Save

Option B: Make Individual Files Public (slower)

  • Click each file → ActionsMake public

🌍 Step 5 (Optional): Use a Custom Domain

To use a custom domain like www.example.com, you’ll need:

  1. A registered domain (via Route 53 or elsewhere)
  2. AWS Route 53 or another DNS provider
  3. CloudFront (recommended for HTTPS + CDN)

I’ll cover that in a separate post — or let me know if you want a tutorial!


🎉 Done! Your Site Is Live

You can now access your site via the S3 website endpoint, like:

http://your-bucket-name.s3-website-us-east-1.amazonaws.com
Enter fullscreen mode Exit fullscreen mode

🧠 Final Tips

  • Use CloudFront to add HTTPS
  • Automate deployments with the AWS CLI or GitHub Actions
  • Keep an eye on S3 costs — it’s very cheap for static sites

Top comments (0)