Amazon S3 (Simple Storage Service) lets you host static websites. Static websites are made up of HTML, CSS, JavaScript, and media files — no server-side code is needed.
This guide will walk you through the steps to set up and publish a static website using an S3 bucket.
Step 1: Create an S3 Bucket
Go to the S3 Console in AWS.
Click Create bucket.
Enter a unique name for your bucket. For website hosting, the bucket name should match your domain name (e.g., example.com).
Choose a region.
Uncheck Block all public access (you'll make the bucket public for web access).
Acknowledge the warning and click Create bucket.
Step 2: Upload Your Website Files
Open your new bucket.
Click Upload.
Add your HTML, CSS, JS, and other static files.
Click Upload.
Step 3: Set Permissions to Make Files Public
You need to make your files publicly readable:
Go to the
Permissions tab
.
Scroll to
Bucket Policy
.
Add a policy like this:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::your-bucket-name/*"
}
]
}
Replace your-bucket-name with the actual name of your bucket.
Step 4: Enable Static Website Hosting
Go to the Properties tab of the bucket.
Scroll to Static website hosting.
Click Edit.
Choose Enable.
Enter the name of your index document (e.g., index.html). You can also add an error document (e.g., error.html).
Save changes.
After saving, you'll see a Bucket website endpoint. This is the URL of your website.
Step 5: (Optional) Use a Custom Domain with Route 53
If you have a domain name, you can use Amazon Route 53 to point it to your S3 site:
Create a hosted zone for your domain.
Add an Alias record pointing to the S3 website endpoint.
Make sure your S3 bucket name matches your domain exactly (e.g., example.com) for this to work.
FAQs
What is Amazon S3 static website hosting?
Amazon S3 static website hosting allows developers to host HTML, CSS, JavaScript, and media files directly from an S3 bucket without managing servers.
Can I host a website on AWS S3 for free?
Yes. Small static websites may fit within the AWS Free Tier limits depending on storage, requests, and bandwidth usage.
Do I need EC2 to host a static website on AWS?
No. Static websites can be hosted directly on Amazon S3 without using EC2 instances or backend servers.
Can I use a custom domain with S3 website hosting?
Yes. You can connect a custom domain using Amazon Route 53 and point it to the S3 website endpoint.
Does Amazon S3 support HTTPS for static websites?
S3 website endpoints do not directly support HTTPS. AWS CloudFront is commonly used to enable HTTPS and CDN support.
Summary
Hosting a static website with Amazon S3 is simple and doesn't require a server. You just upload your files, set public access, and turn on website hosting. You can also link a custom domain if you have one.
Let me know if you need help with custom error pages or adding HTTPS using CloudFront.
Read More Section
Learn practical cloud rightsizing strategies to reduce AWS costs and optimize infrastructure usage.
Compare ECS EC2 and AWS Fargate for scalability, pricing, and operational overhead.
Use AWS Config to monitor infrastructure drift and enforce cloud governance policies.
Prevent deployment failures by monitoring available subnet IPs with AWS Lambda and CloudWatch.
Top comments (1)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.