Terraform is an open-source infrastructure as code (IaC) software tool that enables admin to safely create, change and even burn down your infrastructure (if you so wish). The beauty of Terraform is that it will work with most of the cloud providers including the main ones like Azure & AWS. It has become so popular these days that you can’t ignore it, as organizations are moving to a DevOps team rather than a purely Ops team.
We will look at how to install Terraform on Windows & Mac – from the command line. Yes, you can download the MSI, run it, click next & get it installed. But since we are installing a tool that works with commands & config files, let’s also install the tool the smart way.
Table of Contents
Install Terraform On Windows 10
We can use Chocolatey (or Choco) to install Terraform. Chocolatey is an open source, free package manager for Windows. You can install other software like Chrome, Git, GitHub, Putty etc with a one-liner if you have Chocolatey installed.
If you don’t have Chocolatey installed on your Windows machine, run the command below from PowerShell (run as admin). Make sure that the execution policy for PowerShell is not Restricted.
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Verify the Chocolatey installation by running choco from the command line.
That is the hard part, installing Chocolatey ;-)
Once Chocolatey is on your machine, run the command below to install Terraform
choco install terraform
Press ‘Y’ when you are prompted for the installation confirmation.
That’s it!
Confirm that Terraform has been successfully installed by accessing the terraform help.
Terraform -help
You can install Git or Github or Chrome the same way. Choco install Git, Choco install Github (you get the idea).
Install Terraform On Mac
Similar to Windows, the easiest way to install Terraform on Mac is to use HomeBrew, the package manager for Mac. Most of the Mac users should have Brew already installed, as they are more into command line!
Run the command below from the terminal in case you are new to Mac and don’t have HomeBrew installed.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
In order to install terraform, run the command below (which falls in line with Choco).
brew install terraform
You can verify the installation using
terraform -help
Command line installation is the way to go!
To summarize, we have learned to
- install Chocolatey on Windows,
- HomeBrew on Mac and
- to install terraform on both Windows & Mac.