7. Terraform setup
Finding the right version ¶
1. Pre-requisites ¶
Before you download terraform, you will need to identify which version is required for the code. Terraform updates are released very often - sometimes every week. Our code in qnet-tf and qnet-core is fixed to a specific version and is upgraded only if there's a need for a bug-fix, or if we need new features not available in previous versions of terraform.
Note that terraform version is not the same as the azurerm terraform provider version. Terraform only allows you to define and provision infrastructure in HCL (Hashicorp Configuration Language). The AzureRM provider is the language/syntax that terraform uses to interact with the ARM API. In our environment, AzureRM version upgrades will be more frequent than Terraform version upgrades. More on that later.
If you have access to qnet-tf or qnet-core, you can easily look for the current terraform version under any of the _shared_xxx.tf file.
terraform { required_version = "= 0.12.24" }
Here you can see that the terraform version has been fixed to 0.12.24.
2. Downloading Terraform ¶
Next, go to the terraform release page and download the appropriate version for your operating system.
3. Installing Terraform ¶
On Windows, create a folder called bin under the C: drive and add this folder to the environment variables. You should now be able to use terraform from within CMD or PowerShell.
NOTE: Although you can use Terraform on Windows without any issue, it's strongly recommended to use WLS on Windows for consistency. If using ZSH on WSL, you can easily create aliases/shortcuts to also increase productivity, as explained here
On macOS, run the commands below to use tfenv:
brew install terraform
brew unlink terraform
brew install tfenv
tfenv list-remote
tfenv install 0.13.4
tfenv use 0.13.4
On WSL/Linux, if you have brew installed, you can follow the same steps as macOS above. Else do a manual download and install:
Create a bin directory:
mkdir ~/bin
Download the version by copying the URL from the release page above:
wget https://releases.hashicorp.com/terraform/0.12.24/terraform_0.12.24_linux_amd64.zip
Unzip it:
unzip terraform_0.12.24_linux_amd64.zip
Move it to the bin folder:
mv terraform ~/bin
Verifying install ¶
Once you are done installing, no matter the operating system, run the following to validate the install.
Terraform
terraform version
