Let's Learn Terraform : Part 1 - What is Terraform and How to Install It?
What is Terraform and How to Install It?
In the series of articles we will try to learn Terraform from basics in this article let's discuss what is the Terraform and how to install it in your machine.
What is Terraform?
To say in technical language Terraform is an open source cloud agnostic infrastructure as a code.
Let’s breakdown the above statement and understand in simpler terms.
Cloud Agnostic means it will help to run scripts on any of the cloud providers ( like Azure, GCP, AWS & so on ) so if you write a Terraform script it can be executed on any of the cloud platforms.
So it becomes easier and simpler to perform automation tasks on any of the platforms instead of writing a separate script for each cloud provider, you can write a single script and execute it on any of the cloud providers.
We can create any type of cloud infrastructures using code like create virtual machines, databases or any type of resources. as Terraform is facilitating us to create infrastructures using code hence it is called as infrastructure as a code because it let's build, change and version the infrastructure.
And we all know open source means it is free to use.
How to Install Terraform in Windows Server?
To install Terraform in windows server go to developer.hashicorp.com website and scroll down to windows section and download the 386 as shown in the screenshot below
Note: For most of the Windows machines *386 is compatible but download the setup file based on your machine configurations.
Extract the zip folder that got downloaded and copy the Terraform application to the folder you wish to install Terraform in. Here I am copying it to C drive, I created a folder in C drive and copied the Terraform application to it
Next we need to add the Terraform setup file path in the system environment variables. To do that open windows server settings and search for “edit the system environment variables” as shown in below screenshot
once you click on that a window will open like below. Here click on environment variables
After clicking on environment variables it will open a window where it will show all the existing system variables of your server.
Under system variables select the path and click on edit below
In the new window opened click on new and add the path where you have copied your Terraform application in my case I copied it to C drive Terraform folder, so I'll add that one in case you copied it to some other folder let's say D drive then you need to give that D drive location after that click on Ok
Now click on Ok again and click ok one more time this will close the system properties window.
To execute Terraform scripts we can use multiple user interfaces like VisualStudio, PowerShell etc. Here I am using PowerShell to execute the Terraform scripts so I am opening the PowerShell ISE with administrative permissions.
Open PowerShell ISE run as administrator.
Once the PowerShell ISE opens type the below command
terraform --version
and execute it. If Terraform got installed successfully then you will be able to see the version of Terraform that got installed as shown below
Even if you simply type terraform and execute, it will show the available commands and other details
Now we can proceed with execution of Terraform scripts.
In the next article we will see how we can connect our Azure subscription to terraform.
Thanks VV!!