Skip to main content

DNS Failover with Route53

DNS Failover with Route53

DNS Failover with Route53

Route 53‘s DNS Failover feature gives you the power to monitor your website and automatically route your visitors to a backup site if it…

DNS Failover with Route53

Route 53‘s DNS Failover feature gives you the power to monitor your website and automatically route your visitors to a backup site if the main target is not healthy. To showcase this feature, we are going to deploy an application, which we built in this blog post, to two different AWS regions. We are also going to set active-passive failover in Route53, then we will remove the application from one region and we’ll observe how DNS queries will react to the changes.

AWS describes the failover scenarios in 3 different categories

Active-passive: Route 53 actively returns a primary resource. In case of failure, Route 53 returns the backup resource. Configured using a failover policy.
Active-active: Route 53 actively returns more than one resource. In case of failure, Route 53 fails back to the healthy resource. Configured using any routing policy besides failover.
Combination: Multiple routing policies (such as latency-based, weighted, etc.) are combined into a tree to configure more complex DNS failover.

Follow this blog post and deploy the example stack to two different AWS regions, for this example we will use us-east-1 and us-west-1 regions. To not interfere with CDK state, I would encourage our readers to copy provided CDK example to two different folders.

Deploy the first stack to us-west-1 region

AWS_REGION="us-east-1" cdk deploy

Deploy the second stack to us-east-1 region

AWS_REGION=”us-west-1" cdk deploy

After successful deployments, you should have two load balancers ready for serving requests

EcsGo-Farga-25T9JCLD3XMK-1007273806.us-east-1.elb.amazonaws.com
EcsGo-Farga-1PJH0G7U7G8DA-1685310413.us-west-1.elb.amazonaws.com

Head over to the Route53 console next.

Set the primary record with the ALB in us-east-1 region

Now set the second record with the ALB in us-west-1 region

All good. Before we do something, let’s try our domain first.

You should be seeing a list of dogs in a JSON response.

Now let’s destroy the first stack, this will remove the resources from the us-east-1 region, which we set as a primary record. But no worries, Route53 will now use a secondary record that we set just earlier.

AWS_REGION="us-east-1" cdk destroy

Let’s make sure that first load balancer is not reachable anymore, which we set as a primary record.

And let’s try our domain again

It worked, the secondary target is now serving our requests.


After you are done with the tutorial don’t forget to remove the existing stack we deployed to us-west-1 region.

AWS_REGION="us-west-1" cdk destroy

And delete the A records by selecting each record and then click Delete Record Set in Route53 console.

Popular posts from this blog

Concurrency With Boto3

Concurrency with Boto3 Concurrency with Boto3 Asyncio provides set of tools for concurrent programming in Python. In a very simple sense it does this by having an event loop execute a… Concurrency in Boto3 Asyncio provides a set of tools for concurrent programming in Python . In a very simple sense, it does this by having an event loop execute a collection of tasks, with a key difference being that each task chooses when to yield control back to the event loop. Asyncio is a good fit for IO-bound and high-level structured network code. Boto3 (AWS Python SDK) falls into this category. A lot of existing libraries are not ready to be used with asyncio out of the box. They may block, or depend on concurrency features not available through the module. It’s still possible to use those libraries in an application based on asyncio by using an executor from concurrent.futures to run the code either in a separate thread or a separate process. The run_in_executor() method of the event...

Manage MongoDB Atlas Deployments with AWS CDK

Manage MongoDB Atlas Deployments with AWS CDK Manage MongoDB Atlas Deployments with AWS CDK MongoDB Atlas is a fully-managed cloud-based database service offered by MongoDB. It offers a variety of features such as automatic… Manage MongoDB Atlas Deployments with AWS CDK MongoDB Atlas is a fully-managed cloud-based database service offered by MongoDB. It offers a variety of features such as automatic backups, automatic scaling, and easy integration with other cloud services. AWS Cloud Development Kit(CDK) is a tool provided by Amazon Web Services (AWS) that allows you to define infrastructure as code using familiar programming languages such as TypeScript, JavaScript, Python, and others. MongoDB recently announced general availability for Atlas Integrations for AWS CloudFormation and CDK. In this article, we will go through the process of deploying MongoDB Atlas with AWS CDK. Prerequisites Before we start, you will need the following: An AWS account AWS CDK installed on your lo...

AWS Lambda Function URLs

AWS Lambda Function URLs AWS Lambda Function URLs AWS Lambda is a Serverless computing service offered by Amazon Web Services (AWS) that allows developers to run code without provisioning… AWS Lambda Function URLs AWS Lambda AWS Lambda is a Serverless computing service offered by Amazon Web Services ( AWS ) that allows developers to run code without provisioning or managing servers. In this tutorial, we will explore AWS Lambda Function URLs , which are the endpoints that allow you to invoke your Lambda functions. AWS Lambda Function URLs are unique HTTP endpoints that you can create using AWS Console, SDK or any other IaC tool. These URLs are used to trigger your Lambda function, and they can be integrated with a variety of workloads. Function URLs are dual stack-enabled, supporting IPv4 and IPv6. After you configure a function URL for your function, you can invoke your function through its HTTP(S) endpoint via a web browser, curl, Postman, or any HTTP client. Once you create ...