Hosting a website no longer requires a complex server setup or expensive infrastructure. If you’re looking for a quick, reliable, and low-cost way to publish your HTML/CSS/JavaScript site, then Amazon S3 is your best friend. In this article, I’ll guide you through the complete process of hosting a static website on AWS S3, and we’ll also include a live demo at each key step to make things easy to follow.
** What is Amazon S3?**
Amazon Simple Storage Service (S3) is a highly scalable object storage service offered by AWS. It allows you to store and retrieve any amount of data from anywhere on the internet. From backups and application data to static websites and image hosting, S3 is a powerful tool used by developers and businesses worldwide.
With built-in redundancy, versioning, encryption, and fine-grained access control, S3 is more than just a file storage system — it’s an enterprise-level solution. For this article, we’ll focus on one of its most practical features: hosting static websites.
🌍** Why Use S3 to Host a Website?**
There are many reasons why S3 is perfect for hosting static sites:
No server management: You don’t need to worry about Apache, Nginx, or scaling.
Highly reliable and durable: 99.999999999% durability ensures your files are safe.
Cheap or even free (with the AWS Free Tier).
Fast performance, especially when combined with AWS CloudFront (CDN).
Perfect for portfolios, landing pages, resumes, and documentation websites.
🛠️ Prerequisites
Before you begin, make sure you have the following:
A working AWS account (the free tier is sufficient).
A static website ready to upload. This could be your personal portfolio or a sample HTML/CSS project.
IAM (Identity and Access Management) user credentials — avoid using the root account for safety.
🧭 Overview: 5 Key Steps to Host a Website on S3
Here’s what we’ll be doing in this tutorial:
- Create an S3 bucket
- Upload the website files
- Enable public access
- Set a bucket policy
- Enable static website hosting Let’s dive in.
📦 Step 1: Create an S3 Bucket
After logging in to your AWS Management Console, search for S3 using the top search bar. Click on the S3 service and then click the “Create bucket” button.
You’ll be prompted to enter a unique bucket name (bucket names must be globally unique). Choose your preferred AWS region (like Asia Pacific — Mumbai) and leave most settings at their default.
Click Create bucket, and you’re done! You’ve just created a cloud storage container that will hold your website files.
📁 Step 2: Upload Website Files
Next, open your newly created bucket and click on the “Upload” button. You’ll need to upload your static website files — typically index.html, along with folders for CSS, images, and JavaScript.
It’s important to keep your folder structure consistent so your site behaves the same after upload. Start by uploading the root-level files (like index.html), then add folders like /css, /img, or /js.
Once all files and folders are selected, click Upload and wait until the upload succeeds.
🔓 Step 3: Enable Public Access
By default, all files and buckets in S3 are private. To allow users to access your website, you must enable public access to the bucket.
To do this, go to the Permissions tab of your bucket. Click Edit under “Block public access,” uncheck “Block all public access,” and then confirm your change. AWS may prompt you to type a confirmation statement to avoid accidental misconfiguration.
Once this is saved, your bucket is now publicly accessible — but we still need to set permissions for each file. That’s where the next step comes in.
📝 Step 4: Set a Bucket Policy
Now let’s configure a bucket policy — a JSON-based configuration that defines who can access your bucket and what actions they can perform.
In the Permissions tab, scroll down to Bucket policy, click Edit, and paste this policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::your-bucket-name/*"
}
]
}
Make sure to replace "your-bucket-name" with your actual bucket name. This policy gives the public read-only access to all files in your bucket — exactly what we need for a static website.
Save the policy to apply the settings.
🌐 Step 5: Enable Static Website Hosting
Now for the final touch — let’s tell AWS to serve this bucket as a website.
Go to the Properties tab of your bucket and scroll down to find Static website hosting. Click Edit, then enable the setting.
You’ll need to provide the name of your entry file, usually index.html. You can leave the error document field empty or add error.html if your site has one.
Click Save changes, and AWS will generate a public URL for your website in the format:
ttp://your-bucket-name.s3-website.region.amazonaws.com/
Open this link in your browser — and voila! Your website is live and accessible to the world.
🏁 Final Result
At this point, you’ve completed all the essential steps to host a website on Amazon S3:
You created a secure bucket
Uploaded all required files
Set public access and policies
Enabled static website hosting
Received a live link to your project
You can now share this link with clients, friends, or on your resume. And next time someone asks how to host a simple website, you’ll be ready!
💡 Pro Tips (Optional but Helpful)
Use IAM roles instead of root access for better security and monitoring.
Enable versioning on your bucket to track changes and recover deleted files.
Connect a custom domain via Route 53, and add CloudFront for global speed boost.
If needed, create CI/CD pipelines to auto-upload files using GitHub Actions or AWS CLI.
Top comments (0)