Make Changes to Azure Infrastructure Using Terraform

30 minutes
  • 5 Learning Objectives

About this Hands-on Lab

Hey there, Gurus! Welcome to the lab! This lab will demonstrate how easy it is to manage and destroy infrastructure in Azure with Terraform. You, as an admin, are being asked to deploy a virtual network to Azure and then make some changes to the Azure infrastructure that has been deployed. You will then add a subnet to your test infrastructure and tags to the virtual network that specify the environment and team responsible for resource deployment. After testing the deployment, you will need to destroy all of the resources for the test infrastructure.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Log In and Set Up the CLI

In the Portal

  1. Go to the portal and log in using your lab credentials.
  2. Open the CLI.
  3. Select Bash at the prompt.
  4. Click Show Advanced Settings.
  5. Set the Cloud Shell region to the same location as the resource group.
  6. Select the existing Resource Group, and select Use Existing for the Storage Account.
  7. In the File share section, choose Create new and enter "terraform".
  8. Click Attach Storage.
Deploy the Infrastructure

In the CLI

  1. Download the lab-managing-azure.zip file from the lab’s GitHub repo.
  2. Unzip the lab-managing-azure.zip file.
  3. Change to the lab-managing-azure working directory.
  4. Review the Terraform configuration file.
  5. Add the lab’s Azure Resource Group name to the configuration.
  6. Initialize the working directory.
  7. Apply the Terraform configuration.
Add a Subnet to the Configuration

In the CLI

  1. Download the azure_resource_blocks.tf file from the lab’s GitHub repo.
  2. Review the azure_resource_blocks.tf configuration file.
  3. Add the lab’s Azure Resource Group name to the configuration.
  4. Apply the changes to your infrastructure.
  5. Confirm your changes.
Add a Tag to the Configuration

In the CLI

  1. Edit the main.tf configuration file.
  2. Add the following code to the Virtual Network resource block:
    # Create Tag
     tags = {
       Environment = "TheBatcave"
       Team        = "Batman"
     }
  3. Check the formatting.
  4. Apply the changes to your infrastructure.
  5. Confirm your changes.
Destroy the Infrastructure

In the CLI

  1. Delete your infrastructure using Terraform.
  2. Confirm your changes.

Additional Resources

You are an admin who supports one of the largest online comic book retailers in the world. You are one of a handful of admins who have been assigned to use Terraform to manage the company's cloud deployments. You are asked to start putting together a new Azure test environment. You will deploy the virtual network to test deploying infrastructure to Azure with Terraform. You will then add a subnet to your test infrastructure and tags to the virtual network that specify the environment and team responsible for the resource deployment. After testing the deployment, you will need to destroy all of the resources for the test infrastructure.

Configuration Used in This Lab

Code Added in the Solution Video

    # Create Tag
  tags = {
    Environment = "TheBatcave"
    Team        = "Batman"
  }

What are Hands-on Labs

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.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?