AWS Builder Center
How I Built and Hosted a Static Website on Amazon S3

How I Built and Hosted a Static Website on Amazon S3

A hands-on walkthrough of creating an Amazon S3 bucket, configuring static website hosting, managing ACL permissions, and enforcing JSON bucket policies.

Fueled by relentless pursuit of greatness
Visit my NextWork documentation for more information:


For my very first AWS project, I set out to learn foundational cloud storage concepts, access control lists (ACLs), and cloud hosting techniques. My goal was simple: deploy a live, publicly accessible static website using Amazon Simple Storage Service (Amazon S3). Here is a complete breakdown of how I built it, the challenges I ran into, and how I solved them.



Step 1: Setting Up the S3 Bucket

To kick off the project, I created a globally unique Amazon S3 bucket with ACLs enabled and public access permitted. I chose a region closest to me to minimize latency and speed up website loading times for visitors in the area.
During this setup, I learned two key concepts:
  • Global Uniqueness: S3 bucket names share a single global namespace. Once a bucket name is claimed, no other AWS account across the globe can use it.
  • Access Control Lists (ACLs): These define which AWS accounts or user groups are granted access permissions for specific buckets and objects. Enabling ACLs allowed me to grant public read permissions to individual files later on.
Because AWS provisions cloud storage instantly, the bucket creation took less than five minutes to set up.



Step 2: Uploading Web Assets

Next, I needed to upload the website’s core files:  index.html  (which defines the page structure) and an unzipped folder containing the image assets.
The  index.html  file acts as the primary blueprint for the page, referencing the images stored in the folder. Without the HTML document, the browser wouldn't know how to render the page layout, and without the image assets, the visual content would be broken.



Step 3: Enabling Static Website Hosting

To serve these files as an actual website, I navigated to the Properties tab of my S3 bucket, scrolled down to Static website hosting, and selected Edit. I enabled hosting, chose "Host a static website", specified  index.html  as the index document, and saved the changes.
Upon saving, S3 generated a unique website endpoint URL—the web address used to serve the HTML file directly to visitors over the internet.



Step 4: Troubleshooting the 403 Forbidden Error

When I first opened the S3 website endpoint URL in my browser, I hit a roadblock:
Plaintext
403 Forbidden
Code: AccessDenied
Message: Access Denied

Why it happened: By default, Amazon S3 keeps all uploaded objects private to ensure data security, even if static hosting is turned on at the bucket level.
How I fixed it:
  1. Returned to the Objects tab inside my S3 bucket.
  1. Selected both  index.html  and the images folder.
  1. Clicked Actions and chose Make public using ACL.
Once I confirmed the action and granted public read permissions, refreshing the URL loaded the live site perfectly!



Step 5: Mission Extension – Preventing Accidental Deletion

To take the project a step further, I configured a JSON-based bucket policy to protect critical assets from being deleted.
While ACLs provide fine-grained control over individual files, bucket policies offer centralized permission management across the entire bucket. I attached a policy that explicitly denied  s3:DeleteObject  permissions for  index.html . To test it, I tried deleting  index.html  from the AWS Console, and the action was blocked with an "Access denied" error, confirming the policy was active.


This entire project took me about 30 minutes to complete. The most valuable part was troubleshooting the initial 403 Forbidden error and understanding the distinction between bucket-level hosting and object-level permissions.
  • Services Used: Amazon Simple Storage Service (Amazon S3)
  • Core Concepts Mastered: S3 Buckets, Object Ownership & ACLs, Static Website Hosting, Bucket Endpoints, and JSON Bucket Policies.To take the project a step further, I configured a JSON-based bucket policy to protect critical assets from being deleted.
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