In this hands-on lab, the student 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.
Successfully complete this lab by achieving the following learning objectives:
- Log into 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:
- Clone the GitHub repo for Terraform code
gitcommand to clone the GitHub repo which has the Terraform code for deploying the solution of this lab. GitHub repo URL.
Execute the following command:
git clone https://github.com/linuxacademy/content-deploying-to-aws-ansible-terraform.git
Change to the directory for lab Terraform code:
Examine the contents of the directory you’re in:
- Plug in the Provided Resource Values into `import_resources.tf`
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_id.txtfile in the
Absolute path to the
Complete path to file:
Plug the appropriate value inside the
import_resources.tffile inside the cloned Git repo folder:
- Get Public Hosted Route53 Zone and plug it into variables.tf
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.
Carry out the following steps to fetch the domain and plug it into a variable:
Issue the command:
aws route53 list-hosted-zones | jq -r .HostedZones.Name | egrep "cmcloud*"
This will output a DNS name, ending with a dot.
Copy the DNS value, ensure that you copy the trailing
.at the end as well, and replace it against the default value of the
dns-namevariable in the
- Deploy the Terraform Code
Initialize the Terraform directory you changed into to download the required provider
Ensure Terraform code is formatted properly:
Ensure code has proper syntax and no errors:
See the execution plan and note the number of resources that will be created:
terraform applyhas 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.