AWS Builder Center
Part 05 –How to Host a Website Using AWS S3

Part 05 –How to Host a Website Using AWS S3

Learn how to host a static website using Amazon S3. This beginner-friendly guide covers creating an S3 bucket, uploading website files, configuring static website hosting, and accessing your website online.

Series: AWS Zero to Cloud Builder (8 articles)

  1. …
  2. 4
    Part 05 –How to Host a Website Using AWS S3 This article
Student

How to Host a Website Using AWS S3

Have you ever wondered how a website can be hosted without managing a traditional web server?
Amazon Web Services (AWS) makes this possible with Amazon S3 (Simple Storage Service).
Amazon S3 is a cloud storage service that allows you to store files such as HTML, CSS, JavaScript, images, and documents. It can also be used to host static websites.
In this article, we'll understand how S3 website hosting works and learn how to deploy a simple website step by step.

What is Amazon S3?

Amazon S3 is an object storage service provided by AWS. It stores data as objects inside containers called buckets.
For website hosting, an S3 bucket can store all the files required to display your website.
For example:
  • HTML files – Website structure
  • CSS files – Website design
  • JavaScript files – Website functionality
  • Images – Website visuals
The best part is that you don't need to manage a traditional web server for a static website.

How Does S3 Website Hosting Work?

The process is simple:
  1. Create an S3 bucket.
  1. Upload your website files.
  1. Enable static website hosting.
  1. Configure the required permissions.
  1. Access your website through its website endpoint.
Once configured, visitors can access your website through the provided URL.

Step-by-Step: Host Your First Website Using AWS S3

Step 1: Create an AWS S3 Bucket

  1. Log in to your AWS Management Console.
  1. Search for Amazon S3.
  1. Open the S3 dashboard.
  1. Click on Create bucket.
  1. Enter a unique bucket name, such as  my-first-static-website .
  1. Select your preferred AWS Region.
  1. Create the bucket.
Remember that S3 bucket names must be globally unique.

Step 2: Prepare Your Website Files

Before uploading files, create a simple website on your computer.
Your project structure can look like this:
my-website/
│
├── index.html
├── style.css
└── script.js
You can use the following basic HTML code:
<!DOCTYPE html>
<html>
<head>
<title>My First AWS Website</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Hello from AWS S3!</h1>
<p>My first website is hosted on the cloud.</p>
</body>
</html>

Step 3: Upload Website Files

  1. Open your newly created S3 bucket.
  1. Select the Upload option.
  1. Add your  index.html ,  style.css , and  script.js  files.
  1. Click Upload.
Your website files are now stored in Amazon S3.

Step 4: Enable Static Website Hosting

  1. Open your S3 bucket.
  1. Navigate to the Properties tab.
  1. Scroll down to Static website hosting.
  1. Click Edit.
  1. Select Enable.
  1. Choose Host a static website.
  1. Enter  index.html  as the Index document.
  1. Save your changes.
AWS will now provide a website endpoint for your bucket.

Step 5: Configure Website Permissions

For direct S3 website hosting, visitors need permission to read the website files.
AWS blocks public access by default. For this learning example, you can configure a dedicated bucket containing only public website files.
If you choose direct public S3 hosting:
  1. Open the Permissions tab.
  1. Edit Block public access settings for the bucket.
  1. Review the security warning before changing the settings.
  1. Allow public access only for this dedicated website bucket.
  1. Add a bucket policy that grants read-only access.
Example bucket policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-first-static-website/*"
}
]
}
Replace  my-first-static-website  with your actual bucket name.
Important: This policy makes website objects publicly readable. Never store passwords, private documents, API secrets, or personal information in this bucket.
For production websites, AWS recommends using Amazon CloudFront with Origin Access Control (OAC), keeping the S3 bucket private. AWS Amplify Hosting is another recommended option for static websites.

Step 6: Open Your Website

  1. Go to the Properties tab.
  1. Find Static website hosting.
  1. Copy the Bucket website endpoint.
  1. Open the endpoint in your browser.
Congratulations! Your first website is now hosted using Amazon S3.

Important Things to Remember

  • S3 is suitable for static websites.
  • It can host HTML, CSS, JavaScript, and image files.
  • S3 does not run server-side code such as PHP or Node.js.
  • The direct S3 website endpoint supports HTTP, not HTTPS.
  • CloudFront can provide HTTPS, caching, and improved global delivery.
  • Always review your bucket permissions before making content public.

Why Use Amazon S3 for Website Hosting?

Some important advantages include:
  • Scalability: Store and serve website files without managing a traditional web server.
  • Cost Efficiency: Pay based on the storage and requests you use.
  • Durability: S3 is designed for highly durable object storage.
  • Easy Deployment: Update your website by uploading new files.
  • AWS Integration: Easily integrate with services such as CloudFront and Route 53.

Conclusion

Hosting a website using Amazon S3 is a great way to understand cloud computing practically.
Instead of just learning AWS concepts, you can create a bucket, upload your files, configure hosting, and see your website running online.
If you're a beginner learning AWS, this is a useful hands-on project to add to your cloud computing journey.
In the next article (Part 06), we'll learn how to connect an EC2 instance using SSH and deploy a website on it.
Keep learning, keep building, and keep exploring AWS!

Series: AWS Zero to Cloud Builder (8 articles)

  1. …
  2. 4
    Part 05 –How to Host a Website Using AWS S3 This article
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