Using AWS to Host a Static Website - Part 2
- Jamie Tyler
- Aws
- December 15, 2024
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.
- Register a domain that will be used for the static website. I used Amazon Route 53
- Create the Amazon S3 bucket where the content will be stored ensuring it is not accessible from the Internet (public access)
- Create the public hosted zone using Amazon Route 53 for the registered domain
- Create the SSL certificate for registered domain using AWS Certificate Manager and use DNS validation
- Create the distribution using Amazon CloudFront that uses the Amazon S3 bucket as its source
- 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.
- Navigate to Amazon Route 53. I usually use the search bar or go directly to it here.
- Under Domains, on the left hand menu, and choose Registered Domains.
- On the right hand side click on the Register Domains button. I can search for the desired domain name to register.
- 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.
- By Choosing Select, I have added the domain to the basket. Choosing Proceed to Checkout will progress the order.
- Enter contact information and ensure Privacy protection is checked, choose Next
- Review and check the acceptance of terms and conditions and choose Submit
- 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.