- Lab
- A Cloud Guru
Using Terraform with Azure
Hey, Gurus! Welcome to the Using Terraform with Azure hands-on lab. In this lab, we will cover 3 objectives. First, we will log into the Azure portal and configure the Cloud Shell to use Bash. Second, we check which version of Terraform the Cloud Shell is running. If it is not the latest version, we will update it. In our final objective, we configure Terraform to use the Terraform Azure provider. Instead of jumping around to different screens, this is a quick and easy way to use Terraform with Azure.
Path Info
Table of Contents
-
Challenge
Setup Cloud Shell
In the portal
- Go to the portal and log in using your lab credentials.
- Click the Cloud Shell icon next to the search bar in the portal.
- Select Bash at the prompt.
- Click Show Advanced Settings.
- Set the Cloud Shell region to the same location as the resource group.
- Select the existing Resource Group, and select Use Existing for the Storage Account.
- In the File share section, choose Create new and enter "terraform".
- Click Attach Storage.
-
Challenge
Check the Terraform Version
In the Cloud Shell
- Check the Terraform version in the Cloud Shell.
- If the Terraform version is up to date, proceed to the next objective. If it is out of date, follow the steps below.
- Download the updated Terraform binary from the lab repo to the Cloud Shell.
- Unzip the
terraform_1.1.7_linux_amd64.zip
file. - Create a directory called
bin
. - Move the
terraform
binary to thebin
directory. - Check the Terraform version to confirm you are using the newest version available.
-
Challenge
Configure Terraform Azure Provider
In the Cloud Shell
- Create a working directory called
terraformguru
. - Move into the
terraformguru
working directory. - Create a file called
providers.tf
. - Paste the following code into the
providers.tf
file:terraform { required_providers { azurerm = { source = "hashicorp/azurerm" version = "=2.91.0" } } } provider "azurerm" { features {} skip_provider_registration = true }
- Save the file.
- Initialize your working directory.
- Create a working directory called
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.