Understanding the Basics
What is Amazon S3?
Amazon S3 (Simple Storage Service) is a cloud-based object storage service from Amazon Web Services (AWS). It's designed to store and retrieve virtually unlimited amounts of data from anywhere on the web. Think of it as a super-powered online hard drive for your files.
For more information on S3, check out the video below:
What is a static site?
Static websites are built entirely with HTML, CSS, and maybe some client-side JavaScript. They don't rely on a server to generate content on the fly, making them simple, fast, and often more affordable to host. For more information, see Hosting a static website using Amazon S3.
Set Up Your AWS S3 Static Website
Create an AWS Account and S3 bucket
Enable Static Website Hosting
index.html
.Make Your Bucket Public
confirm
into the provided field to verify that you understand the security implications and intentionally wish to make the bucket public. Important: By enabling public access, anyone on the internet will be able to see the files in your bucket. Make sure you only store content intended for public viewing.
Apply a Bucket Policy (For Public Read Access)
your-bucket-name
with your actual bucket name:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadForGetBucketObjects",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::your-bucket-name/*"
}
]
}
Bucket Policy Explanation
-
Version:
"2012-10-17"
Specifies the version of the policy language being used. - Statement: [ ... ] This is an array containing one or more individual policy statements. In this case, we have a single statement. Let's break down that statement:
-
Sid:
"PublicReadForGetBucketObjects"
A "Statement ID", a simple identifier or label for this particular statement. -
Effect:
Allow
Determines whether the statement grants permissions (Allow) or denies them (Deny). -
Principal:
"*"
Specifies who the policy applies to. The asterisk (*) means "everyone" (i.e., public access). -
Action:
s3:GetObject
The specific Amazon S3 action that's being allowed. In this case, it's the ability to read/retrieve objects from the bucket. -
Resource:
"arn:aws:s3:::your-bucket-name/*"
The Amazon Resource Name (ARN) specifying the S3 bucket and objects to which this policy applies. You'll need to replace"your-bucket-name"
with your actual bucket name. The asterisk at the end (*) means all objects inside the bucket are affected.
Apply Bucket Policy
Upload and Access Your Website
http://your-bucket-name.s3-website.your-region.amazonaws.com
.