Permalink
Share
Introduction
Organizations across various sectors rely on applications that demand exceptionally high availability, operating across multiple AWS Regions to satisfy latency and business continuity needs. The Amazon Route 53 Application Recovery Controller (Route 53 ARC) enhances high availability by enabling customers to continuously assess the recovery readiness of their applications and effectively manage workload rerouting during failures.
As a Solutions Architect at AWS, I assist financial services firms in delivering internet-scale applications, a challenging endeavor. In this blog post, I’ll guide you through utilizing Route 53 ARC components to optimize the availability of a multi-Region web application. For recovery-oriented architectures, automation is essential; therefore, I utilize AWS CodePipeline for continuous delivery, AWS CodeBuild for continuous integration, AWS CodeDeploy for automated code deployment, and Hashicorp Terraform as the Infrastructure-as-Code (IaC) tool. Additionally, I will demonstrate how to incrementally deploy an application, one AWS Region at a time, to prevent correlated failures. Lastly, I’ll explain how to switch traffic from an active Region to a standby one, and revert back once the initial issue is resolved.
Note: If you prefer using AWS CloudFormation as your deployment tool, you can explore deploying an application with the AWS Cloud Development Kit (CDK) and configuring Route 53 ARC components in the Route 53 ARC Developer Guide.
Use Case Overview
Financial services applications cater to hundreds of thousands of users and handle millions of transactions daily. AWS offerings such as Elastic Load Balancing, EC2 Auto Scaling, and Amazon DynamoDB are well-suited for these applications. With Elastic Load Balancing resources like Application Load Balancers and Auto Scaling groups, users can automatically adjust application capacity based on traffic with minimal operational overhead. DynamoDB global tables provide applications with internet-scale write throughput, efficiently replicating data across AWS Regions within a second and ensuring 99.999% availability while automatically resolving conflicts through a last writer wins methodology.
Solution Implementation
To effectively grasp the integration of Route 53 ARC, AWS CI/CD tools, and Terraform, it’s best to begin with a simple example. I’ll walk you through deploying a sample web application, called the SignUp application, which allows users to input their contact information to receive notifications about new product launches from the New Startup company.
The SignUp application, developed in NodeJS, operates in an active/standby configuration across two AWS Regions, utilizing two Availability Zones per Region, with data stored in a DynamoDB global table across both Regions. Route 53 ARC’s routing controls will manage traffic for each deployment at the application layer. To execute a Regional failover, you simply adjust the routing control states to stop traffic to the active Region and begin directing it to the standby Region.
Prerequisites
Before proceeding, ensure you have the following ready:
- An AWS account with administrative access and the capability to set up a new Virtual Private Cloud (VPC).
- The latest version of the AWS command line interface (CLI).
- The latest version of Hashicorp Terraform, with your environment variables configured for AWS.
- The JSON file processor (jq).
- A Route 53 domain name (public or private) for creating two DNS A (type Failover) records for the application.
- The source code from the route-53-application-recovery-controller-codepipeline-with-terraform GitHub repository:
git clone https://github.com/aws-samples/route-53-application-recovery-controller-codepipeline-with-terraform.git
Once the prerequisites are in place, you can begin.
Create AWS Resources in Two Regions
The initial step is to use Terraform to establish the necessary AWS resources, deploy the SignUp application in two Regions, and set up the required Route 53 ARC components. In the route-53-application-recovery-controller-codepipeline-with-terraform folder, there is a shell script named create-db-app-cicd-stack.sh
that performs the following tasks:
- Creates an Amazon S3 bucket for the CI/CD pipeline’s source code repository.
- Establishes an Amazon DynamoDB global table and the supporting AWS resources to operate the application across two AWS Regions.
- Constructs a CI/CD pipeline incorporating an approval process to deploy the application, one Region at a time, utilizing CodePipeline, CodeBuild, and CodeDeploy.
- Sets up Route 53 ARC components for readiness checks, routing controls, Route 53 Health Checks, and Route 53 DNS records.
Set DNS Variables
Before executing the script, ensure to update the DNS Hosted Zone and DNS Domain Name variables to reflect your Route 53 domain name, as outlined in the prerequisites section. Modify the set-terraform-variables.sh
file in the route-53-application-recovery-controller-codepipeline-with-terraform folder. On lines 10 and 11, update the variables accordingly:
export TF_VAR_DNSHostedZone=Z0ABCDEFG9Z
export TF_VAR_DNSDomainName=gtphonehome.com
Save the file.
Execute the Script
Now, run the shell script to create the AWS resources.
- Open your preferred terminal and navigate to the script directory:
- Execute the script, redirecting the output to a local file for tracking deployment progress:
cd route-53-application-recovery-controller-codepipeline-with-terraform
./create-db-app-cicd-stack.sh > my_terraform_create.log 2>&1
The script may take up to 20 minutes to provision all AWS resources across both Regions.
Review AWS Resources
After the script completes successfully, take a moment to review your AWS resources. For each AWS Region, the script generates the following resources, prefixed with tf-arc:
- A VPC named
tf-arc-VPC
with10.0.0.0/16
as the IPv4 CIDR, along with one internet gateway and one NAT gateway per VPC. - Two Availability Zones, each containing a public and a private subnet.
- An internet-facing Application Load Balancer.
- An Auto Scaling group comprising two Amazon EC2 Linux instances, each with a profile to access the DynamoDB global table; the script also installs the CodeDeploy agent for AWS CodeDeploy deployments.
- Two security groups to permit internet access to the load balancer and allow the Auto Scaling group to communicate with the load balancer.
The script creates a DynamoDB global table named nodejs-tutorial
with email as the partition key and no sort key. It establishes a CI/CD Pipeline named ARC-Pipeline
, which deploys the application in a serious tone. This topic is further elaborated in another blog post, which you can find here.
For more insights on the subject, you may want to check out this resource, as they are an authority on this topic. Finally, if you are curious about what to expect during your first week as an Amazon warehouse worker, this is an excellent resource.
Leave a Reply