How to Install Terraform on Windows System
However, before you can create a resource using Terraform, you need to install it on your system. In this beginner friendly post, I will show you, how to install Terraform on windows system.
Let’s go ahead…
How to Install Terraform ?
Terraform is distributed as a single binary package. You can install Terraform manually or using a package manager for windows like chocolatey.
1. Install Terraform on Windows Manually
In this section, we will see how we can install terraform manually on a windows system including environment variable setup.
Step 1: Download Terraform Binary Package
Navigate to official Terraform download page
Go to windows tab, and you will see two different options as shown below-
Choose Amd64 if your windows system is of 64 bit and choose 386 if your system is 32 bits. Just click on that link and the package gets downloaded as zip archive in your system as seen below.
Step 2: Unzip the Archive
Copy the downloaded archive into a specific folder where you want to keep terraform. After copying, just extract/unzip the binary.
Step 3: Setup Windows Path Variable
Why to Set Path?
You might say that, I installed terraform and now I can use it. Well you can if you try it from same folder. However, if you try it out from any other folder or path, you will have to specify full path of the package every time which is very very inconvenient.
Setting the PATH variable for a program allows you to run it from anywhere on the system without having to specify its absolute path.
Now we know why we need to set path, lets go ahead and set it up.
Once you unzip the package, go inside the folder and you see terraform application. Copy the path from the address bar as shown below and keep it handy as we will need it during environment variable setup.
In the windows menu search bar, type ‘environment‘ and click on Edit system environment variable
As soon as you click on it, it opens below window
Click on Environment Variables and a window opens like below.
From the bottom section in the above screenshot for system variables, select Path variable and click Edit
Click New, paste the terraform path in the box and hit enter.
Click OK. click OK again as two window gets opened up in the process.
Step 4: Verify Terraform Installation
Once you have done Path setup, you can verify terraform installation by using terraform –version command from command line.
As you hit enter, you see the version of the terraform installed in your system as seen above.
If you got that, congratulation !!!
If not and you get terraform not recognized error, close the command line and open a new one. You can also try running below command and windows should detect it.
Automated Way to Install Terraform on Windows
Installing terraform manually although not difficult, but needed quite a few steps. lets see how can we automate this. If you are using a windows system, you can use the package manager chocolatey.
Chocolatey is a package manager for windows. It lets you install software on your system without much manual efforts. In simple words if I say, it is windows equivalent of yum or apt-get
If you don’t already have chocolatey installed in your system, use this tutorial to install it in your system : How to Install Chocolatey on Windows
Once installed, you should run choco –version command to see if was installed correctly. This is how it looks like:
If you are here, I assume you already have chocolatey installed in your system. So let’s go ahead and install terraform.
Install Terraform using Chocolatey
Open a command prompt or PowerShell terminal and hit below command.
choco install terraform
Once you hit enter, terraform is installed on your system and an entry to path is added as well all by your package manager automatically.
So that was fairly easy . Wasn’t it?
All you needed was to run a simple command-
choco install terraform
And that’s it.
As I said in the manual installation section, you can again verify the installation using below command.
You have successfully installed terraform on your windows system either way. Go ahead and start experimenting by creating various resources on your favorite cloud provider.
Small Note: Chocolatey and the Terraform package are NOT directly maintained by HashiCorp. The latest version of Terraform is always available by manual installation.
In this post on “How to Install Terraform on Windows System”, we learnt to install terraform on windows in two ways.
- Manually by downloading archive, unzipping and setting path
- Automatically using choco install terraform command
We also saw that, as per HashiCorp, chocolatey and it’s terraform package are not managed by HashiCorp. Therefore, in case you see it’s not installing latest one, you can always use manual installation to install it.
I hope you were able to install it on your system. Please let me know in comment section in case you have any doubt.
Enjoyed the content?
Subscribe to our newsletter below to get awesome AWS learning materials delivered straight to your inbox.
Don’t forget to motivate me by-
- Adding a comment below on what you liked and what can be improved.
- Follow us on
- Share this post with your friends