AWS Builder Center

How to Host a Static Website on Amazon S3

Learn how to host a static HTML, CSS, and JavaScript website using Amazon S3, including bucket configuration, public access, and website hosting.

How to Host a Static Website on Amazon S3

Amazon S3 (Simple Storage Service) is an object storage service provided by AWS. Besides storing files, S3 can also be used to host static websites.
In this article, we will deploy a simple HTML website using Amazon S3.

What We Need

  • An AWS account
  • A simple HTML/CSS/JavaScript website
  • Amazon S3
  • A web browser

Step 1: Create an S3 Bucket

  1. Sign in to the AWS Management Console.
  2. Open Amazon S3.
  3. Click Create bucket.
  4. Enter a unique bucket name.
  5. Select your preferred AWS Region.
  6. For this tutorial, keep the remaining settings as default.
  7. Create the bucket.
The bucket name must be globally unique across Amazon S3.

Step 2: Upload Your Website

Open the bucket and select Upload.
Upload your website files, for example:
1
2
3
4
index.html
style.css
script.js
images/
After uploading, the files will be stored as objects inside your S3 bucket.

Step 3: Enable Static Website Hosting

Go to:
Bucket → Properties → Static website hosting
Enable static website hosting and select:
1
2
Hosting type: Host a static website
Index document: index.html
Save the changes.
S3 will provide a website endpoint that can be used to access the static website.

Step 4: Configure Access

For a basic public static website, the objects need to be accessible to visitors.
Go to:
Permissions → Block public access
Configure the bucket according to your hosting requirements and acknowledge the warning if you intentionally want public access.
Then configure an appropriate bucket policy that allows s3:GetObject for the website objects.
Example:
1
2
3
4
5
6
7
8
9
10
11
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/*"
}
]
}
Replace:
1
YOUR-BUCKET-NAME
with your actual bucket name.
Security note: Public access is not always the best architecture. For production websites, Amazon CloudFront with a private S3 bucket is generally a better approach.

Step 5: Open the Website

Return to:
Properties → Static website hosting
Copy the Bucket website endpoint and open it in your browser.
If everything is configured correctly, your index.html page should appear.

How the Architecture Works

The basic architecture is:
1
2
3
4
5
6
7
8
9
10
11
12
User
|
v
S3 Website Endpoint
|
v
S3 Bucket
|
+-- index.html
+-- style.css
+-- script.js
+-- images/
The browser requests the website files from Amazon S3, and S3 returns them to the user.

Advantages of S3 Static Website Hosting

  • No server to maintain
  • Simple deployment
  • Highly scalable storage
  • Pay-as-you-go pricing
  • Integrates with other AWS services
  • Suitable for static websites and frontend applications

Important Limitation

S3 static website hosting is designed for static content.
It cannot directly execute backend code such as:
1
2
3
4
Node.js
Python
Java
PHP
For applications requiring backend processing, you can combine S3 with services such as:
  • Amazon EC2
  • AWS Lambda
  • Amazon API Gateway
  • Amazon DynamoDB

Conclusion

Amazon S3 provides a simple way to host static websites without managing a traditional web server.
For learning AWS, this is a useful project because it introduces important concepts such as S3 buckets, objects, permissions, IAM policies, and cloud-based hosting.
Once you understand basic S3 hosting, you can extend the architecture using CloudFront, Route 53, HTTPS, and CI/CD for a more production-ready deployment.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article