How to Create Failover DNS Record Sets in Route 53

Introduction

You have been working hard to architect and build a highly available, fault tolerate, scalable elastic web application in AWS. You have included all the appropriate components, including but not limited to:

(1) An Elastic Load Balancer serving traffic to EC2 instance in multiple subnets, spread across multiple availability zones

(2) An Auto Scaling group set for on-demand scaling.

(3) CloudWatch alarms set to trigger SNS topics if something goes wrong

(4) Multi-AZ failover for your RDS databases

(5) Pilot lights set up for rapid deployment to other regions

(6) Automated EBS backups via cronjobs

However, as you look at your architecture, you feel that something is missing. What if the entire region goes down? What if the ELB breaks? What if Auto Scaling fails and all your instances overload and crash? In that situation, it will take time for you to spin up the application in another region. What will happen to your customers in the meantime? Currently, they would just get an error when trying to access the application. After some thought, you realize that you must set up some kind of failover solution at the highest level, so if everything inside the region fails, your customers will at least get some kind of message when they access your web application. The answer you decide upon is to configure your Route53 DNS records to have a failover component, so if the current environment becomes unstable, your domain name will point to a failover message to inform your customers of the issue. But how do you set that up?

Lucky for you, Route 53 has the ability to easily configure DNS record sets specifically for failover scenarios. These failover record sets can be configured to failover to full-blown deployments in other regions or to a static HTML page that informs your customers of the issue. It is that latter scenario which we are going to focus on here – reviewing how to configure failover to an HTML file in an S3 bucket.

Getting Started

Section 1: Set Up the S3 Environment

1) Create a bucket in S3.

a. The bucket MUST have the same name as your website.

2) Create a static HTML file that you want to be displayed in the event of the failover.

3) Upload it to the bucket you just created.

4) Change the objects permission to “read” for “everyone”.

5) Go to your bucket permissions and enable “Static website hosting”.

a. Select “use this bucket to host a website”.

b. Enter the name of the static HTML file in the field labeled “Index Document”.

Section 2: Create and Configure the Route 53 DNS failover Record Sets

1) In Route 53, go to “hosted zones” and select your domain.

2) First, you have to create your primary failover record set. If you already have an “A” record set pointing to the ELB, then you can still follow these steps to update the existing record set.

a. Click on “create record set”.

b. Input the name (usually WWW or non-WWW).

c. Leave the type of “A” (for normal IPV4 connections).

d. For Alias, select “yes”.

e. For Alias Target, click in the field and find the ELB for your application.

f. For Routing Policy, select “Failover”.

g. For Failover Record Type, select “primary”.

h. For Set ID, leave as “Primary”.

i. For Evaluate Target Health, select “Yes”.

i. This allows Route53 to monitor the ELB. If the ELB fails, or if all the instances associated with the ELB fail/become unhealthy, Route 53 is notified.

j. For Associate with Health Check, select “No”

k. “Create” the record set.

You have now created the primary failover record set. This is the record set that points your domain name to your application and will be used when everything is working properly.

3) Next, we have to create the secondary failover record set. This will be the record set that takes over if the health check on the primary record set fails.

a. Click on “create record set”.

b. Input the name (usually WWW or non-WWW – must be the same selection as above).

c. Leave the type of “A” (for normal IPV4 connections).

d. For Alias, select “yes”.

e. For Alias Target, click in the field and find the S3 bucket that you created earlier.

f. For Routing Policy, select “Failover”.

g. For Failover Record Type, select “Secondary”.

h. For Set ID, leave as “Secondary”.

i. For Evaluate Target Health, select “No”.

j. For Associate with Health Check, select “No”.

k. “Create” the record set.

Section 3: Sit back and relax knowing that you now have DNS failover configured!





  • post-author-pic
    Sean G
    07-31-2017

    Nice! Thanks Thomas for another great guide!

Looking For Team Training?

Learn More