Creating a Static Website Using Amazon S3
Create S3 Bucket
- Navigate to the S3 portion of the AWS Management Console.
- Create a bucket, choosing a globally unique name.
- Select US East (N. Virginia) region.
- Click Next.
- Leave options as defaults; click Next.
- Under permissions, uncheck all four permissions restrictions.
- Click Next.
- Click Create bucket.
- Select bucket name.
- Click Upload.
- Add files (use your own or those from the sample website).
- Click Upload.
Enable Static Website Hosting
- Click the bucket name.
- Navigate to Properties > Static website hosting.
- Select Use this bucket to host a website.
- For Index document, enter index.html.
- For Error document, enter error.html.
- Click Save.
Apply Bucket Policy
Navigate to Permissions > Bucket policy.
Add the following JSON statement (replacing with your bucket name):
{
"Version":"2012-10-17",
"Statement":[{
"Sid":"PublicReadGetObject",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::<my-bucket>/*"]
}]
}
Ensure the trailing /* is present so that the policy applies to all objects within the bucket.