Semper Cogitare

Hosting on AWS #

The site is static, and completely hosted on AWS using a combination of S3 and Cloudfront. Here are the steps I followed to set it up.

  1. Create an AWS root account
  2. Use the root account to create an IAM user and perform all following actions as that user
  3. In Route53 purchase the domain sempercogitare.co.uk which will create a hosted zone for it
  4. In S3 create a bucket called www.sempercogitare.co.uk
    1. When creating it choose to block all public access to the bucket
    2. Add a test index.html into the root of the bucket
  5. In Cloudfront create a new function called add_index_html
function handler(event) {

var request = event.request;
var uri = request.uri;

// Check whether the URI is missing a file name.
if (uri.endsWith('/')) {
request.uri += 'index.html';
}
// Check whether the URI is missing a file extension.
else if (!uri.includes('.')) {
request.uri += '/index.html';
}

return request;
}
  1. In Cloudfront create a new distribution
    1. The origin will be the S3 bucket you have just created
    2. Under Origin access choose Origin access control settings
    3. Choose the Origin access control for the bucket
    4. Follow the instructions AWS gives you to add the policy to the S3 bucket. This gives this Cloudfront distribution access to the S3 bucket.
    5. Under Viewer protocol policy select Redirect HTTP to HTTPS
    6. Associate the add_index_html with Viewer request
    7. Under Settings, add CNAMEs for sempercogitare.co.uk and www.sempercogitare.co.uk
    8. Request a custom SSL certificate with FQDN sempercogitare.co.uk. Add a second name of www.sempercogitare.co.uk. Follow the instructions that AWS gives you to do this.
    9. Set the default root object to index.html
  2. Once the distribution has been created, grab its domain name (dddddddd.cloudfront.net) and head back over to Route53
    1. In Hosted zones select sempercogitare.co.uk and create a new record with the following properties
      1. subdomain - none (leave blank)
      2. record type - a
      3. value - dddddddd.cloudfront.net (the Cloudfront distribution domain name)
    2. Create another new record with the following properties
      1. subdomain - www
      2. record type - cname
      3. value - dddddddd.cloudfront.net (the Cloudfront distribution domain name)

Test by visiting all variations:

All four should return the site.