Hosting: React Static S3
Some Notes on Static S3 Hosting with an S3 Bucket, CloudFront, ACM and Route 53
Summary
- Register a domain
- Create NS record in Route 53
- Confirm Nameservers switched in registrar
- Create an S3 bucket
- Upload website files to your bucket including index.html
- Enable website hosting on your bucket
- Create a CloudFront distribution.
- Request an ACM public certificate
- In ACM request a certificate for your domain,
- Create CNAME records in Route 53
- Add A record for each subdomain in Route 53
- Deploy distribution
- Test page
S3 Bucket
- Create an S3 bucket with the name of the domain you want to use. For example, if you want to use
www.example.com
, create a bucket namedwww.example.com
. - Enable static website hosting on the bucket.
- Make index.html your root file
- Upload static files to the bucket.
CloudFront Distribution
Create a CloudFront distribution.
Set the origin domain name to the S3 bucket.
Set the alternate domain names to the domain you want to use. For example,
www.example.com
.Set the SSL certificate to the ACM certificate you created for the domain.
Cloudfront distribution creation page notes
- Origin domain - s3 bucket
- Origin access Legacy access identities
- Bucket policy - YES, update the bucket policy
- Viewer protocol policy - Redirect HTTP to HTTPS
- GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE
- Custom SSL certificate - optional
- Alternate Domains
* guitarsnow.com
* www.guitarsnow.com - Request certificate - see ACM part below
- index.html for root object response/error
- Default root object - optional
- Description
ACM Certificate
* Request a public certificate
* Fully qualified domain name Info
* Example:
* guitarsnow.com
* www.guitarsnow.com
* *.guitarsnow.com
* Create CNAME Records in Route 53
* Create A Records in Route 53
Test domain DNS, if issues
- Use Route 53 tool in AWS
- DNS checker: https://dnschecker.org/
Errors
- Registrar DNS errors:
- ACM SSL cert will not validate if the nameserver at your registrar is not correct.
- Check the nameserver in the registrar and make sure it matches the nameserver in Route 53 hosted zone.
- Amazon errors:
- Missing index.html file
- Index.html not set as root object
- Cloudfront alternate domains not set