Using AWS to Host a Static Website - Part 2

Using AWS to Host a Static Website - Part 2

Table of Contents

In Part 1 I talked about the AWS services used to host a static website and the use of Infrastructure-as-Code (“IaC”) to deploy and, ultimately maintain the infrastructure that underpins it. In this post, I am going to talk about the sequence that the AWS services need to be created in.

The Sequence

Understanding the sequence that AWS resources have to be created in ensures that there is little to no rework when creating the IaC aka static website deployment automation. When creating a static website that is hosted on AWS following this sequence ensures that all services are created and that their dependency on each other is satisfied. This all starts with a registered domain name. AWS does not need to be used as the registrar but for this example I have as it simplifies this a little.

  1. Register a domain that will be used for the static website. I used Amazon Route 53
  2. Create the Amazon S3 bucket where the content will be stored ensuring it is not accessible from the Internet (public access)
  3. Create the public hosted zone using Amazon Route 53 for the registered domain
  4. Create the SSL certificate for registered domain using AWS Certificate Manager and use DNS validation
  5. Create the distribution using Amazon CloudFront that uses the Amazon S3 bucket as its source
  6. Create DNS records in the public hosted zone that aliases the Amazon CloudFront distribution using

At the time of writing this post, CloudFormation cannot be used to automate domain registration. As this is, generally, a one time thing its not a big issue.

Registering a Domain Using Amazon Route 53

Although this is straight forward, for completeness, I am including it in the sequence using “ClickOps” i.e. the AWS Console. I already have many registered AWS accounts so I have signed into one of those.

Note

AWS update their UI frequently so it may not be exactly like this.

  1. Navigate to Amazon Route 53. I usually use the search bar or go directly to it here.
  2. Under Domains, on the left hand menu, and choose Registered Domains.
  3. On the right hand side click on the Register Domains button. I can search for the desired domain name to register.
  4. For this post, I am going to register nostrom0.cloud for use through the preceding posts. It is available and will cost $25 per year. AWS is not the cheapest but I am doing this for simplicity of management. I entered the domain and chose search.
  5. By Choosing Select, I have added the domain to the basket. Choosing Proceed to Checkout will progress the order.
  6. Enter contact information and ensure Privacy protection is checked, choose Next
  7. Review and check the acceptance of terms and conditions and choose Submit
  8. It will return to registered domains with the status message the registration is being processed

Selecting Requests will allow for monitoring the progress and when complete it will show something like the following.

Conclusion

In this post I have walked through the sequence to host a static website using AWS services and that IaC, CloudFormation, will be used to deploy these services and, finally, walked through the process to register a domain to use with the static website using AWS as the register.

In the next post, I will walk through the sequence and IaC for creating an Amazon S3 bucket that will be used for the content of the static website.


Using AWS to Host a Static Website - Part 3

Related Posts

Using AWS to Host a Static Website - Part 4

Using AWS to Host a Static Website - Part 4

In part 3 I walked through the creation of the Amazon S3 bucket where the static website content will reside. In this post I will walk through using CloudFormation to create an Amazon Route 53 public hosted zone. This is automatically created when a domain is registered using Amazon Route 53 so this is for completeness and is not required for this series of posts.

Read More
How to use a Password Manager to Store AWS Credentials

How to use a Password Manager to Store AWS Credentials

I like to have a way of avoiding having to have access_key_ids and secret_access_keys locally configured on my Mac.

Read More
Using AWS to Host a Static Website - Part 6

Using AWS to Host a Static Website - Part 6

In part 5 I created the SSL certificates to use with the static website. In this post, I am going to deploy Amazon CloudFront for the CDN portion. Before I do that, I am going to upload the static HTML files that will be rendered.

Read More