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.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- 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.
- 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.
- 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