https://docs.aws.amazon.com/AmazonS3/latest/userguide/website-hosting-custom-domain-walkthrough.html
https://support.cloudflare.com/hc/en-us/articles/360037983412-Configuring-an-Amazon-Web-Services-static-site-to-use-Cloudflare
Create 2 s3 buckets – domain.com and www.domain.com
In first s3, Enable: Static website hosting
Note the “ENDPOINT”
On second s3, Enable: Static website hosting, set “Redirect requests for an object” -> Target bucket: domain.com
Buckets -> Properties -> Server access logging – Enable
Permissions -> Set “Block all public access” – untick all.
Add bucket policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::Bucket-Name/*"
]
}
]
}
Add DNS : domain.com to endpoint , www.domain to domain.com
CNAME flattening – With CNAME flattening, Cloudflare finds the IP address that a CNAME points to.