AWS Route 53 with Terraform
Tags: aws, terraform, awsroute53, cdn
Published: 2021-05-25 21:53:01

In this article we will imagine that your team received two very important pieces of information. The first being about issues regarding the company website and the second being about the future of your company.

First, the Social media team has revealed to your team that a significant proportion of your customer base are leaving bad reviews about the stability of your website. Customers describe that the website has been down frequently during the past month on different days of the week and at random times during the day.

Secondly and part of the good news is that the company started looking into moving their online business from their on-premise environment to a public cloud provider.

For this project the company’s main requirements are:

- Scalable cloud Domain Name System (DNS) webserver
- Very reliable
- Highly available
- Cost effective

Your team received the task to conduct research on the three big public cloud providers on the market and to create a presentation with the best options for this migration. Your manager has given you the task to provide details about Amazon Website Services (AWS) DNS server and to present a proof of concept (POC) in front of your company directors to provide a representation of what this infrastructure would look like in the cloud.

**Research stage**

As your research advances you discover that AWS-Route53 provides the following functions:

- Domain registration
- DNS service
- Health checking
-Private DNS resolution within VPC’s using private hosted zone

***Looking promising already – right?***

**Development stage**

Looking at the research stage looks like AWS-Route53 has great components that could help with company requirements.

**How can AWS-Route53 could help us with our issue?**

Health checking is a great feature that AWS-Route53 uses to send automated requests over the internet to applications verifying that it is working, accessible and available. In addition, AWS-Route53 has different policies that can be used under different circumstances.

**Types of policies:**

- Routing policies
- Simple routing policy
- Weighted routing policy
- Latency based routing policy
- Failover routing policy
- Geolocation routing policy

**In this stage you will focus on building and deploying the following AWS-services:**

- Availability zone
- VPC
- Public subnet
- Internet gateway
- Route table
- EC2
- Security groups
- Elastic Ip
- Route 53
- S3 bucket

**For readability some services are not included on this diagram: AWS-Route 53 Failover routing policy**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lpra7xxedguodstpyk2h.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rgcsiryqwquefsqnhflz.png)

**Conclusion**

On the day of your presentation, you will be able to showcase a full AWS-Route53 Failover routing policy demo where a primary record, the EC2 instance, will automatically switch over to a secondary backup record, an S3 bucket, after the primary indicated a failure on the AWS-Route53 health check. And because you are all about code you will be using Terraform to provision this deployment.

>"Everything fails, all the time"

[AWS CTO, Werner Vogels](https://cacm.acm.org/magazines/2020/2/242334-everything-fails-all-the-time/fulltext)

And servers that host websites are no exception. Servers and systems can fail for several reasons. However, having backup plans ensures that when such problems occur users of the application do not experience any downtime.

**Note** to be able to complete this project you will need a domain.

**Functions, arguments and expressions of Terraform that were used in the above project:**

[providers](https://www.terraform.io/docs/language/providers/index.html)
[variables](https://www.terraform.io/docs/language/values/index.html)
[modules](https://www.terraform.io/docs/language/modules/index.html)
[resources](https://www.terraform.io/docs/language/resources/index.html)
[types and values](https://www.terraform.io/docs/language/expressions/types.html)

[Find the Terraform repo and directions for this project here](https://github.com/ValAug/AWS_Route53_Terraform)