Using AWS S3 and CloudFront for Static Website Hosting
The pieces to the puzzle are:
A domain name.
example.com
for the purpose of this discussion. Use Route53 to search for and buy the name. Not surprisingly, this is an up front purchase rather than the “pay as you go”, model you’ll find for most Amazon services. For a basic .COM, domain expect to pay $12 / year.S3 bucket. Actually you’ll need two. Create a bucket named the same as your domain name. This bucket will hold your static web content. the second bucket (optional) setups a redirect from www.example.com to example.com
SSL/TLS Certificate. These are free from Amazon Certificate Manager. When creating the certificate for your domain make sure to include both the root domain name, and the
www
subdomain.CloudFront Distribution. Amazon CloudFront is the service that actually serves up your web content, that it gets from S3. You’re users are not getting the content from S3 directly. (That is possible if your happy with HTTP only, which you shouldn’t be.) When creating a CloudFront distribution you’ll provide alternate domain names that you own (both the root domain name and the
www
subdomain) You can expect the building of the Distribution to take up to 30 minutes.A couple A records in for your domain. These records will point to the CloudFront Distribution, rather than an actual IP address
There are a ton of step by step guides 1, 2, 3 on line that walk you through the step by step, so there is no need to repeat that here.
Notes on setting up this blog site
When configuring the CloudFront distribution the first field to complete is the Origin Domain Name. This is an “interesting” field, in that you’re able to supply a value, but if you click into the field it will behave as a dropdown and allow you to select from a variety of sources. When you pick an S3 bucket from the dropdown list, while it will appear to work, you’ll lose the index.html default values on sub folders that S3 is providing. You must supply the endpoint name of your bucket which is available in the property window in S3 for the static web site hosting feature.
The only other issue was missing the adding of the www
as an additional domain name in the certificate.
Last updated: 12 Jun 19 14:17 -0400