amazon-web-servicesamazon-s3hostingamazon-cloudfrontjamstack

How do I host an SSL static site using S3 and Namecheap?


Note: sitenamehere is not the name of the site. Redacted it for personal reasons.

I've got a static site sitting at http://www.[sitenamehere].site.s3-website-us-west-1.amazonaws.com/ -- it's working fine, publicly accessible.

I want to make it available via sitenamehere.site and www.sitenamehere.site (where the first redirects to the 2nd). My understanding is that I will need 3 things to get this to work:

  1. A cert via AWS cert manager (verified via DNS records)
  2. A Cloudfront distribution that points to an S3 bucket
  3. An S3 bucket that has publicly accessible html
  4. Updated DNS records on Namecheap

It seems to me that I have all 3. But when I go to the site I get www.sitenamehere.site’s server IP address could not be found.

In namecheap's DNS panel I have a CNAME record:

Type: CNAME

Host: _5ee8b630d994d9efexxxxxxxxxxxx - (the original value was _5ee8b630d994d9efexxxxxxxxxxxx.sitenamehere.site but Namecheap support told me to only use the first portion)

Value: _4998f8b754e7f59ce4d6xxxxxxxxxxxx.mzlfeqexyx.acm-validations.aws.

ACM says the cert is validated (Validation Status: Success)

Next up: Cloudfront. I have one distribution and its Origin Domain Name is www.sitenamehere.site.s3.amazonaws.com. That value was available in a drop down when editing the Origin (Edit Origin screen). Origin ID: S3-www.sitenamehere.site Restrict Bucket Access is No. This all seems correct to me.

Next up: S3. I have a few buckets on here but the one I'm targeting is called www.sitenamehere.site. That's the one that I have the Cloudfront dist pointed at. It's fully public and has

 "Principal": "*",
 "Action": "s3:GetObject",

in its bucket policy.

This all looks like it should be working but it's not. What's missing?


Solution

  • you should do two more things.