If you landed here, I assume you know what Terraform is and why to use it. If that’s not the case, check out the monolog on my video below that covers those topics. This post, however, is dedicated to the steps required to prepare a Windows 10 computer for Terraform. The steps are similar if using Windows 11. The most significant difference is the start menu is in the center bottom of your screen.
There are three components required before using Terraform with Azure. You need, well, Terraform, the Azure Command Line Interface (CLI), and an editor. The example here will use VSCode for the editor because it’s free and works very well.
As already stated, Windows 10 is used to configure the environment. Don’t feel left out if you are not using Windows. The steps are similar for Linux and macOS.
Let’s get started with Terraform.
First, download Terraform from the link below. Then, select the version that matches your system.
Terraform comes as a single executable. It’s not packaged as an installable file. We need to extract the file and move it to a folder on the computer.
Create a folder at the root of the C:\ drive called Terraform.
Next, go to System Environment Variables on the system.
Go to System Properties and Environmental Variables.
Find Path under System Variables. Select that and click Edit.
Click OK to exit out of system properties.
Adding that directory to the path statement will allow us to run the terraform command from any directory on the system without specifying C:\Terraform.
Next, let’s go back to downloads, right-click on Terraform and extract.
Extract Terraform to the C:\Terraform directory.
Next, open a command prompt and type terraform version. You should see something like the image below. That indicates Terraform is installed. Close the command prompt, and let’s move on.
If the command doesn’t work, verify the path statement is entered correctly, and the terraform.exe file is in the correct directory.
Next, let’s install the Azure CLI. Use the Azure CLI to connect to and deploy resources in Azure. Go to the download link below. Notice there are options for macOS and Linux on the left side of the page for those so inclined.
Download the MSI installer and run once finished downloading.
You will need to agree to the terms and can click next to keep the default settings.
Once finished, open a new command prompt, and type “az version”. You should get a response similar to below.
That indicates the Azure CLI is installed. Close the command prompt, and let’s move to the next step.
Like before, we need to download a file. The VSCode installer is found at the link below.
Download the version that corresponds to your system. For windows, use the User Installer if you don’t have admin access to the computer.
Once downloaded, run the installer. Accept the terms and click through the default settings.
Launch VSCode once finished.
VSCode is installed, but we’re not finished yet. Go to Extensions on the left side of the screen.
From here, we’ll install three extensions. An extension adds functionality to VSCode. It adds features such as advanced language support, autocomplete, and other features that make VSCode easier to use.
The first one we’ll install is “Azure CLI tools”, search for and install that extension.
Next, search for and install the HashiCorp Terraform extension. Look for the one by HashiCorp
Next, search for “Bracket Pair Colorizer”. Install version 2. Bracket Pair Colorizer is optional but helpful for formatting with complex files.
Test the Environment
There are a couple more steps before we finish. First, go to Terminal, New Terminal.
Enter “Terraform Version”. You should see the same output as before, similar to the image below.
Do the same for the command “az version”.
Once that’s in place, we are ready to get started with Terraform. The next video on the Terraform workflow and creating a deployment can be found here: https://www.ciraltos.com/terraform-workflow-with-azure-write-plan-and-apply/