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
- Go to AWS S3 Console
- Click “Create bucket”
- Enter a globally unique bucket name (e.g.,
my-portfolio-site
) - Choose a region
- Uncheck “Block all public access” (you’ll make it public later)
- Acknowledge the warning and click Create Bucket
📤 Step 2: Upload Your Website Files
- Click on the newly created bucket
- Click “Upload” → “Add files”
- Select all your static files (index.html, styles.css, etc.)
- Click “Upload”
🌐 Step 3: Enable Static Website Hosting
- Go to the “Properties” tab of the bucket
- Scroll to “Static website hosting”
- Click “Edit”, select Enable
- Set:
-
Index document:
index.html
- (Optional) Error document:
error.html
- 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
- Go to Permissions > Bucket policy
- 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/*"
}
]
}
- Click Save
Option B: Make Individual Files Public (slower)
- Click each file → Actions → Make public
🌍 Step 5 (Optional): Use a Custom Domain
To use a custom domain like www.example.com
, you’ll need:
- A registered domain (via Route 53 or elsewhere)
- AWS Route 53 or another DNS provider
- 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
🧠 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)