- Lab
- A Cloud Guru
Use Output Variables to Query Data in Azure Using Terraform
In this lab, we will demonstrate the usefulness of adding output variables to your configuration and how they can be used to collect data about resources in your infrastructure. In this lab, we will first deploy the virtual network to test deploying to the new Azure test environment, along with a subnet. You will then add some output variables to a file to output the virtual network name and the subnet name, expanding on your configuration and adding some outputs that you can use later to easily access these values. Once you have finished testing, you will then destroy your test infrastructure.
Path Info
Table of Contents
-
Challenge
Deploy the Infrastructure
- In the CLI, download the source files from the lab GitHub repo:
https://github.com/pluralsight-cloud/Use-Output-Variables-to-Query-Data-in-Azure-Using-Terraform
- Change to the
Use-Output-Variables-to-Query-Data-in-Azure-Using-Terraform
working directory. - Review the Terraform configuration file.
- Add the labs Azure Resource Group name and Subscription ID to the configuration.
- Initialize the working directory.
- Apply the Terraform configuration.
- In the CLI, download the source files from the lab GitHub repo:
-
Challenge
Add the Outputs Variable File
- Create an outputs file named
outputs.tf
. - Add the following code to the
outputs.tf
file:
output "azurerm_virtual_network_name" { value = azurerm_virtual_network.vnet.name } output "azurerm_subnet_name" { value = azurerm_subnet.subnet.name }
- Apply your changes to the infrastructure.
- Inspect the ouput of your
apply
command. - Confirm your outputs can be displayed whenever needed.
- Create an outputs file named
-
Challenge
Destroy the Test Infrastructure
- Destroy your infrastructure after successful deployment.
- Confirm destruction.
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.