CloudFormation template for a CloudFront enabled S3-Website
This is the template discussed in the previous post for serving a static website stored in S3 through CloudFront.
Enabling HTTPS
Previously our website was served directly from S3 which meant our friendly domain name (e.g. blog.m-taylor.co.uk) could not deliver content via HTTPS.
Adding in CloudFront removes this limitation. Our Route53 record points at CloudFront where the custom domain is configured. CloudFront is terminating the SSL with our ACM certificate so the visitor will receive that all important green tick in their browser.
The Template
You need a few things to get this template running. They are explained in the parameters section of the template, but in summary you need
- A pre-existing Route53 Hosted Zone where our DNS record can be created
- A CloudFrontAccessIdentity (unfortunately these cannot be created by CloudFormation)
- A fully validated certificate in ACM in the eu-west-1. The certificate must be in this region, irrespective of which you are launching the CloudFormation stack