Host a website for free on Amazon S3 with SSL
https://www.lukeko.com/11/host-a-website-for-free-on-amazon-s3-with-ssl 0- Create a bucket (note the region which will be used in step 7) called www.example.com. It's not necessary but I also recommend turning on versioning so it's possible to rollback changes
- Properties > Static website hosting > Turn on
- Permissions > Block Public Access
- uncheck "Block All public access"
- check "Block public access to buckets and objects granted through new access control lists (ACLs)"
- check "Block public access to buckets and objects granted through any access control lists (ACLs)"
Permissions > Bucket Policy
{ "Version": "2012-10-17", "Statement": [ { "Sid": "PublicReadForGetBucketObjects", "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::www.example.com/*" } ] }
On your domain host: Subdomain forward example.com → http://www.example.com, Permanent redirect (301), Forward path, Enable SSL
Go to https://console.aws.amazon.com/acm/home > create a certificate for example.com and www.example.com and validate
Go to https://console.aws.amazon.com/cloudfront/home > Create distribution
- Origin Domain Name: www.example.com.s3-website-us-east-1.amazonaws.com
- Viewer Protocol Policy: Redirect HTTP to HTTPS
- Compress Objects Automatically: yes
- Alternate Domain Names (CNAMEs): example.com www.example.com (on separate lines)
- Default Root Object: index.html
- SSL Certificate > Custom SSL Certificate and select certificate from previous step
www CNAME xxx.cloudfront.net.
To update the cache after updating the website, go to CloudFront and create an invalidation with object paths /