Hosting a Static Website on AWS S3

Hosting a static website on AWS S3 is a cost-effective and scalable solution. This guide walks you through setting up your own static site with just a few steps.

Step 1: Clone My Git Repo

Grab the sample files from my GitHub:

git clone https://github.com/malcolmso/aws

Step 2: Create an S3 Bucket

  1. Log in to your AWS Console.
  2. Navigate to S3 and click “Create Bucket.”
  3. Provide a unique bucket name.
  4. Select a region and adjust settings as needed.
  5. Click “Create Bucket.”

Step 3: Upload Your HTML Files

  1. Open the bucket.
  2. Click “Upload” and add index.html and error.html.
  3. Click “Upload” to confirm.
Upload HTML files to S3

Step 4: Enable Static Website Hosting

  1. Go to the Properties tab of your bucket.
  2. Scroll to Static Website Hosting → Edit.
  3. Enable hosting and set:
Index Document: index.html
Error Document: error.html

Click “Save.” Then note your bucket endpoint:

http://your-bucket-name.s3-website-us-east-1.amazonaws.com/

Step 5: Update Bucket Permissions

  1. Go to PermissionsBucket Policy → Edit.
  2. Copy your Bucket ARN:
arn:aws:s3:::your-bucket-name

Use the AWS Policy Generator to build a public-read policy:

  • Policy Type: S3 Bucket Policy
  • Effect: Allow
  • Principal: *
  • Action: s3:GetObject
  • ARN: arn:aws:s3:::your-bucket-name/*

Click Add Statement → Generate Policy. Paste the result into the Bucket Policy editor and click Save.

Step 6: Test the Website

Open the endpoint in your browser and confirm the site loads correctly 🎉

Static hosting configuration Bucket policy setup