Intro

You want to start using Terraform to manage your Azure infrastructure. To get started you will need to get your local development environment setup. In this post I will walk you through setting up Terraform and the Azure CLI on Windows.

For a video walkthrough check out my YouTube video.

PowerShell

I’m a huge fan of PowerShell so that is my preferred way to interact with Terraform. If you are using Windows you will already have a version of PowerShell available on your machine. I like to use the latest and greatest so I start by installing the latest version which as of this writing is 7.3.1. Download the package and install it, you’re done.

https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.3#msi

Azure CLI

In order for Terraform to interact with Azure you will need to have the Azure CLI installed on your machine. Download the package and install it, you’re done.

https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-windows?tabs=azure-cli

Terraform

Installing Terraform is easy but there isn’t an installer to do the work for you. Follow these steps.

  1. Download the latest version of Terraform, 1.3.7 as of this writing.
    https://developer.hashicorp.com/terraform/downloads
  2. Extract the contents of the zip file and place it in a folder of your choice. I am using C:\Terraform.
     
  3. Add Terraform to your environment variables. I put Terraform in C:\Terraform so I will need to add that to the path variable. I won’t walk through the steps for doing that here because it has been well documented by others. Below is a written walkthrough and a video walkthrough on how to add a new item to the Path environment variable.
    Written Steps: https://stackoverflow.com/questions/1618280/where-can-i-set-path-to-make-exe-on-windows
    Video Walkthrough: https://www.youtube.com/watch?v=ow2jROvxyH4

Finishing Up

To ensure everything recognizes all the new packages and new configuration, reboot your machine. Once Windows has rebooted we will check the versions of all software we just installed.

  1. Check PowerShell version
    $PSVersionTable.PSVersion
  2. Check Azure CLI version
    az –-version
  3. Check Terraform version
    terraform –version