Static Site Using S3
Hosting static site on AWS S3
1.1. Use S3
At first, I tried to host Github Pages for a home page. However, github says I need to upgrade github account or make repository public to host web page. So, I decided host my minimal page to Amazon S3.
According to Amazon S3 User Guide Hosting a static website using S3,
Amazon S3 website endpoints do not support HTTPS. For information on how to use HTTPS with your Amazon S3 bucket, see:
- AWS account
- Web page content
3. Create S3 bucket
AWS console > Amazon S3 > Bucket > Create Bucket
- Bucket name (following Bucket naming rule)
- AWS region
- Check off “Public Access Control” (at this point)
- Check off “default server-side encryption” (at this point)
4. Enabling website hosting
- In the Buckets list, choose the name of the bucket
- Choose Properties
- Under Static website hosting, choose Edit.
- Choose Use this bucket to host a website.
- Under Static website hosting, choose Enable.
- Specify index document (e.g. “index.html”)
- Specify error document (e.g. “error.html”) for 4xx class errors.
5. Block Public access
5.1. Open public access to Bucket
- Go to S3 console > select bucket > Permissions
- Clear “Block all public access” and save
5.2. Add Bucket policy (permit read access)
- At Permission for the bucket, set bucket policy by JSON (with changing “Bucket-Name” to your bucket name)
6. Upload web content
- Go to S3 console > Object > Upload:
- Drug and drop from local file
7. Check website endpoint
Bucket > Properties > Static website > Bucket website endpoint
Then you can see hosted web page.