Why Host a Static Site on S3?
Amazon S3 (Simple Storage Service) is one of the most cost-effective and reliable ways to host a static website. Since static sites — built with plain HTML, CSS, and JavaScript — don't require a server to process requests, S3's object storage is a perfect fit. You get 99.999999999% (11 nines) durability, global availability, and costs that often amount to just a few cents per month for low-traffic sites.
This guide walks you through the complete setup: from creating your S3 bucket to making your site live with a custom domain and HTTPS via CloudFront.
What You'll Need
- An AWS account (free tier is sufficient for getting started)
- Your static website files (HTML, CSS, JS, images)
- AWS CLI installed and configured (optional but recommended)
- A registered domain name (optional, for custom domain setup)
Step 1: Create an S3 Bucket
- Log in to the AWS Management Console and navigate to S3.
- Click Create bucket.
- Enter a bucket name. If you're using a custom domain, name it exactly after your domain (e.g.,
www.yourdomain.com). - Choose your preferred AWS Region (pick one geographically close to your audience).
- Under Object Ownership, select ACLs disabled.
- Uncheck Block all public access — this is required for static website hosting. Acknowledge the warning.
- Click Create bucket.
Step 2: Enable Static Website Hosting
- Open your newly created bucket and go to the Properties tab.
- Scroll down to Static website hosting and click Edit.
- Select Enable.
- Set the Index document to
index.html. - Optionally set an Error document (e.g.,
404.html). - Click Save changes. Note the Bucket website endpoint URL — this is your site's S3 address.
Step 3: Set a Bucket Policy for Public Access
Go to the Permissions tab of your bucket and click Bucket policy. Paste in the following policy, replacing YOUR-BUCKET-NAME with your actual bucket name:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/*"
}
]
}
Click Save changes. Your bucket objects are now publicly readable.
Step 4: Upload Your Website Files
- Go to the Objects tab and click Upload.
- Add all your website files (ensure
index.htmlis at the root level). - Click Upload.
Alternatively, use the AWS CLI for faster uploads: aws s3 sync ./your-site-folder s3://YOUR-BUCKET-NAME
Step 5: Add HTTPS with CloudFront (Recommended)
S3 static website hosting alone only serves over HTTP. For HTTPS — which is essential for SEO and security — add a CloudFront distribution in front of your bucket:
- Navigate to CloudFront in the AWS Console and click Create distribution.
- Set the Origin domain to your S3 bucket website endpoint (not the bucket itself).
- Under Viewer protocol policy, select Redirect HTTP to HTTPS.
- Request an SSL/TLS certificate via AWS Certificate Manager (ACM) — it's free.
- Add your custom domain as an Alternate domain name (CNAME).
- Deploy the distribution (takes 10–15 minutes).
Step 6: Point Your Domain to CloudFront
In your domain registrar's DNS settings, create a CNAME record pointing www.yourdomain.com to your CloudFront distribution domain (e.g., d1234abcd.cloudfront.net). For the apex domain (without www), use an ALIAS record if your DNS provider supports it, or use Route 53.
Congratulations — Your Site Is Live!
Once DNS propagates (usually within an hour), your static site will be live over HTTPS with global CDN delivery. Total running cost for a low-traffic personal or small business site is typically well under $1 per month. For updates, simply re-run your aws s3 sync command or re-upload changed files through the console.