Jul 12, 2018

Convert an AWS S3 bucket to static web site

You need to set some configuration options that enable the bucket to be used for static website hosting.

This configuration enables the objects in the bucket to be requested using a registered public DNS name for the bucket, as well as direct site requests to the base path of the DNS name to a selected website homepage (index.html in most cases):

aws s3 website s3://YOUR_BUCKET_NAME --index-document index.html

All buckets created in Amazon S3 are fully private by default. In order to be used as a public website, we need to create an S3 Bucket Policy that indicates objects stored within this new bucket may be publicly accessed by anyone. Bucket policies are represented as JSON documents that define the S3 Actions (S3 API calls) that are allowed (or not not allowed) to be performed by different Principals (in our case the public, or anyone).

aws s3api put-bucket-policy --bucket REPLACE-ME-YOUR-BUCKET-NAME --policy file://path/to/your/policy.json