- Lab
- A Cloud Guru
Creating Route 53 Records (Alias) to Route Traffic to an ALB Using Terraform
In this hands-on lab, you will be creating a Route 53 alias record to route traffic from a publicly hosted zone in Route 53 (already provided by A Cloud Guru Lab Environment) to an application load balancer using Terraform template(s). Please note that changes to Route 53 records may take some time to propagate.
Path Info
Table of Contents
-
Challenge
Log in to the Terraform Controller Node EC2 Instance
-
Find the details for logging in to the Terraform Controller node provided by the hands-on lab interface and log in to the node using SSH.
Note: This instance already has an EC2 instance profile (role) attached to it and has all necessary AWS API permissions required for this lab. It also has the AWS CLI set up and configured with the AWS account attached to this lab, for which the console login credentials are also provided in the lab interface page once the lab spins up.
-
After logging in, verify the version of Terraform installed (should be 12.29). Execute the following command to check.
-
-
Challenge
Clone the GitHub Repo for Terraform Code
-
Use the
git
command to clone the GitHub repo which has the Terraform code for deploying the solution of this lab. GitHub repo URL. -
Change to the directory for lab Terraform code.
-
Examine the contents of the directory you're in.
-
-
Challenge
Plug in the Provided Resource Values into the import_resources.tf File
-
You will need the values for a few pre-configured resources to complete this lab, such as Security Group IDs. These values can be found in the
resource_ids.txt
file in thecloud_user
home directory.- Absolute path to the
resource_ids.txt
file:
/home/cloud_user/resource_ids.txt
- Complete path to file:
/home/cloud_user/resource_ids.txt
- Absolute path to the
-
Plug the appropriate value inside the
import_resources.tf
file inside the cloned Git repo folder.
-
-
Challenge
Get Public Hosted Route53 Zone and Plug It into the variables.tf File
-
A publicly-hosted domain is provided for you as part of this lab and your Terraform controller node has the permissions to make API calls to Route 53 to fetch it.
-
Fetch the domain and plug it into a variable.
-
Copy the DNS value, ensure that you copy the trailing
.
at the end as well, and replace it against the default value of thedns-name
variable in thevariables.tf
file.
-
-
Challenge
Deploy the Terraform Code
-
Initialize the Terraform directory you changed into to download the required provider
terraform init
-
Ensure Terraform code is formatted properly:
terraform fmt
-
Ensure code has proper syntax and no errors:
terraform validate
-
See the execution plan and note the number of resources that will be created:
terraform plan
-
Deploy resources:
terraform apply
Enter
yes
when prompted.After
terraform apply
has run successfully, you can either use the AWS CLI on the Controller node to list and describe created resources or you can log in to the AWS Console to verify and investigate created resources. -
Finally, on the Terraform Controller node CLI, delete all resources which were created and ensure that it runs through successfully.
terraform destroy
-
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.