Terraform from HashiCorp is provided as a command-line tool that must first be installed before it can be used. It’s provided as a single executable that can be downloaded and then used directly from the Windows Command Prompt or PowerShell. This means Terraform does not have a traditional Windows Installer application to install. It’s rather simpler than that. You basically download the executable (exe) and can run it where ever you are.

With Terraform distributed as a single executable file, it’s really easy to embed the terraform.exe in a Git or other source code repository to include the Terraform version with the code for your Terraform project. However, it’s really convenient to have Terraform installed on your local machine, so you can just type terraform in the Command Prompt or PowerShell directly to execute it.


Install Terraform on Windows

The following steps will guide you through installing HashiCorp Terraform on Windows and make it available to execute from any Windows Command Prompt or PowerShell prompt:

  1. Download the Terraform executable from HashiCorp. You can choose the supported version you wish to download from the official HashiCorp Terraform download page.
  2. Extract the downloaded .zip file from HashiCorp to the directory of your choosing to place the terraform.exe executable on your machine. An easy to access location to extract Terraform to is C:\terraform\ or you can choose another folder on your machine that you desire.
  3. Update the System’s global path to include the location of the Terraform executable to make it available from anywhere on the Windows Command Prompt or in PowerShell. You can see instructions on updating the System’s global path below.
  4. Open a Windows Command Prompt or PowerShell window and run Terraform commands.

Check Terraform Install and Version

To easily check if Terraform is already installed, or even check which version is installed, run the following command:

terraform version

If Terraform is installed, you will see the output of which version is installed. If not installed, then you will see the usual error that the Command Prompt or PowerShell are unable to find / run the command.

The Windows Command Prompt showing results of running Terraform version command.
The Windows Command Prompt showing results of running Terraform version command.

Update the System’s Global Path for Terraform

Downloading and extracting the HashiCorp Terraform executable to the local machine makes it available to use. However, you will need to specify the location of the executable every time you run a Terraform command unless you add the path to Terraforms location to the system’s global path within Windows.

The following steps will guide you through updating the System’s global path to include Terraform so it’s made available to the Windows Command Prompt and PowerShell prompts:

  1. Open the Advanced System Settings. This can be found by searching within the Windows Control Panel, or by searching for it within the Start Menu search feature.
  2. Click the Environment Variables… button.
    Install Terraform on Windows for use in Command Prompt and PowerShell 1
  3. On the Environment Variables dialog, locate and select Path under System Variables, then click the Edit button.
    Install Terraform on Windows for use in Command Prompt and PowerShell 2
  4. On the Edit environment variable dialog, click the New button, enter the path to where Terraform is located (such as C:\terraform), then click the OK button to save it.
    Install Terraform on Windows for use in Command Prompt and PowerShell 3
  5. Click OK on the Environment Variables dialog to close it.
  6. To test, open the Command Prompt or PowerShell and run terrafrom version or any other Terraform command from any folder / directory location.

Happy Terraforming!

Microsoft MVP

Chris Pietschmann is a Microsoft MVP (Azure & IoT) and HashiCorp Ambassador (2021) with 20+ years of experience designing and building Cloud & Enterprise systems. He has worked with companies of all sizes from startups to Fortune 100. He is also a Microsoft Certified Azure Solutions Architect and developer, a Microsoft Certified Trainer (MCT), and Cloud Advocate. He has a passion for technology and sharing what he learns with others to help enable them to learn faster and be more productive.
HashiCorp Ambassador (2021) Microsoft Certified Trainer (MCT) Microsoft Certified: Azure Solutions Architect