Amazon Simple Storage Service (Amazon S3)
AWS S3 Basic Features
Demo Static Website
In this tutorial, you’ll learn how to deploy a simple static website using Amazon S3. We’ll cover:
- Project file structure
- Configuring S3 for static hosting
- Setting public access and custom error pages
- Testing your site endpoint
This guide is ideal for developers and DevOps engineers looking to serve HTML, CSS, and images directly from S3.
Project Structure
Your local directory (static-demo/
) contains:
index.html
– Main gallery pageindex.css
– Layout and styling rules404.html
– Custom error pageimages/
– JPEG photos used in the gallery
index.html
This HTML file defines the page structure and references your CSS and images:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="index.css" />
<title>Food Gallery</title>
</head>
<body>
<div class="container">
<div class="images">
<!-- Nine food images displayed in a grid -->
<div class="image"><img src="images/food1.jpg" alt="Food 1" /></div>
<div class="image"><img src="images/food2.jpg" alt="Food 2" /></div>
<div class="image"><img src="images/food3.jpg" alt="Food 3" /></div>
<div class="image"><img src="images/food4.jpg" alt="Food 4" /></div>
<div class="image"><img src="images/food5.jpg" alt="Food 5" /></div>
<div class="image"><img src="images/food6.jpg" alt="Food 6" /></div>
<div class="image"><img src="images/food7.jpg" alt="Food 7" /></div>
<div class="image"><img src="images/food8.jpg" alt="Food 8" /></div>
<div class="image"><img src="images/food9.jpg" alt="Food 9" /></div>
<div class="image"><img src="images/food10.jpg" alt="Food 10" /></div>
</div>
</div>
</body>
</html>
Your accompanying index.css
defines a responsive grid layout, background colors, and typography. Place all JPEGs in the images/
folder.
404.html
When users request a missing resource, S3 serves this custom error page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="index.css" />
<title>Page Not Found</title>
</head>
<body>
<div class="container">
<h1 class="head-404">404</h1>
<h2 class="text-404">Page not found</h2>
</div>
</body>
</html>
Note
You can preview both pages locally by opening index.html
in your browser. The CSS grid will display your food gallery.
1. Create an S3 Bucket
- Open the Amazon S3 console and click Create bucket.
- Enter a unique bucket name (e.g.,
kk-static-demo
) and select your region. - Keep default settings and click Create bucket.
Once created, locate your bucket in the list:
2. Upload Website Files
- Click your bucket name to open it.
- Drag & drop
index.html
,index.css
,404.html
, and theimages/
folder into the console. - Choose Upload and confirm.
3. Enable Static Website Hosting
- In your bucket, navigate to Properties → Static website hosting → Edit.
- Select Enable.
- For Index document, enter
index.html
. - For Error document, enter
404.html
. - Save changes.
Review the bucket’s static hosting properties:
You should see a Bucket website endpoint listed:
At this point, clicking the endpoint yields Access Denied since the bucket is private.
4. Configure Public Access
4.1 Disable Block Public Access
- Go to Permissions → Block public access (bucket settings) → Edit.
- Uncheck Block all public access and confirm.
4.2 Add a Bucket Policy
Still under Permissions, select Bucket policy and paste the following JSON (replace the ARN with your bucket name):
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowPublic",
"Principal": "*",
"Effect": "Allow",
"Action": ["s3:GetObject"],
"Resource": ["arn:aws:s3:::kk-static-demo/*"]
}
]
}
Save the policy. Alternatively, use the Add a resource UI:
Your bucket will now appear publicly accessible:
Warning
Making your bucket public exposes all objects. Ensure only intended files are uploaded.
5. Test Your Static Website
Return to Properties → Static website hosting and click the endpoint link. You should see the food gallery home page.
You do not need to append /index.html
—the index document is served automatically.
Resource | URL Pattern |
---|---|
Home page | http://kk-static-demo.s3-website-<region>.amazonaws.com/ |
Explicit index | http://kk-static-demo.s3-website-<region>.amazonaws.com/index.html |
Specific image | http://kk-static-demo.s3-website-<region>.amazonaws.com/images/food1.jpg |
Missing resource (404 page) | http://kk-static-demo.s3-website-<region>.amazonaws.com/does-not-exist |
References
Watch Video
Watch video content
Practice Lab
Practice lab