These three sample Terraform templates show you how to configure Amazon Route 53 Application Recovery Controller automatically. Please see Terraform's documentation for the AWS provider to learn more. In this guide, we will use the following Terraform/AWS resource categories:
The Terraform templates described here are specific to the TicTacToe demo application deployed with this CDK script. For more information about AWS Cloud Development Kit, go to the AWS CDK documentation.
Listed below are the three sample Terraform templates:
To use these Terraform templates, you must have a hosted zone on Route 53 (either public or private).
Before you run the Terraform templates, install the TicTacToe demo application by using the supplied CDK script.
Please make sure to install AWS CDK v2. The CDK scripts do not work with AWS CDK v1.
# Install CDK 2, if you haven't already done so
npm install -g aws-cdk@next
# Download the CDK script that allows to deploy the app
wget https://r53-application-recovery-controller-terraform-app-iad.s3.amazonaws.com/tictactoe-infra-cdk-arc-terraform-templates.zip
unzip tictactoe-infra-cdk-arc-terraform-templates.zip
cd tictactoe-terraform/app
# first time only (one time operation)
&& cdk bootstrap
npm install
# deploy the app
cdk deploy --all --outputs-file ../out.json
The application deployment takes ~10 minutes to complete. The database stack creation might take up to 10 minutes. You will be prompted 3 times for confirmation (y/n?), always answer y
. Three CloudFormation stacks are created :
TictactoeAppCdkStack-us-east-1
: the application stack deployed in us-east-1
regionTictactoeAppCdkStack-us-west-2
: the application stack deployed in us-west-2
regionTictactoeDatabaseCdkStack
: the database stack, it is a DynamoDB global table deployed in us-east-1
and us-west-2
and shared by the two application stacks.Now that the application is deployed, you are ready to deploy the Route 53 Application Recovery Controler (ARC) Terraform templates.
ℹ️ CDK output file
The TicTacToe CDK deployment script generates a file (out.json
) that contains information about the resources that the script creates.
The Terraform templates expects the following parameters:
AWS Regions: Regions where the TicTacToe AWS resources are deployed: us-east-1
and us-west-2
DNS hosted zone: Update line 7 of the "arc_terraform/set-system-variables.sh" script with a value that corresponds to your AWS environment
DNS domain name: Update line 8 of the "arc_terraform/set-system-variables.sh" script with a value that corresponds to your AWS environment
Prefix of AWS resources: Terraform will create your new AWS resources with this prefix. Tf-TicTacToe
is the default value. If you want to change it, update line 16 of the "arc_terraform/set-system-variables.sh" script
Application-specific resources: The "arc_terraform/set-system-variables.sh" script parses the out.json
file to automatically populate the following information for variables in the Terraform templates:
The Terraform Readiness Checks template creates the following resources to model the TicTacToe application in Application Recovery Controller:
The Terraform Routing Controls template creates a cluster in Application Recovery Controller, along with other routing control infrastructure:
us-east-1
and us-west-1
The Terraform DNS Records template can be used to configure the required Route 53 DNS failover records for the routing control health checks:
us-east-1
us-west-2
Both DNS records are associated with the corresponding health checks created earlier.
The first step is to run the terraform init
command only once to initialize the arc_terraform
working directory, which contains Terraform configuration files. Open a terminal and type:
# assuming you're in the main directory of this project
cd arc_terraform
terraform init
To help run the Terraform templates, I provide the "arc_terraform/0-create-route53-arc-components.sh" script. Open a terminal and type:
# assuming you're in the main directory of this project
cd arc_terraform
./0-create-route53-arc-components.sh
After a few minutes, Application Recovery Controller is fully configured. You can now use the Amazon Route53 Console to review the components.
Routing controls are simple on/off switches that manage traffic flow to the us-east-1
and us-west-2
cells in your recovery group. When a routing control state is ON
, traffic flows to the cell controlled by that routing control.
After you run the Terraform templates, both routing controls are turned off. Follow the steps in the AWS documentation to turn one of the routing controls on by using the Amazon Route53 console or by using the AWS CLI
You are now ready to visit the application using the new DNS failover record. Check your hosted zone on the Amazon Route 53 console. Feel free to turn on and turn off one routing control at a time to see how the application traffic is rerouted to the healthy Region.
Happy testing!
After you're done testing Application Recovery Controller, run the following script to clean up all of the Route 53 resources that you created:
# assuming you're in the main directory of this project
cd arc_terraform
./99-destroy-route53-arc-components.sh
You can reach Guillermo Tantachuco at tantag@amazon.com. Thank you.