Terraform from HashiCorp is provided as a command-line tool that must first be installed locally before excution. It’s easy to install, as the full tool is contained within a single executable. This makes it easy to put terraform in any folder on your machine for use. Although, to make it executable from anywhere on your system it needs to be installed, like when you put an executable like this in the /usr/local/bin location. Then you can simply type terraform to execute it from within any folder on your system. This article will take a look at the methods of installing Terraform locally on both macOS and Linux.
Bash Script to Install Latest Version of Terraform on macOS and Linux
While package managers are great, there may be a time when you want to install Terraform yourself instead. You could go to the Terraform release page form HashiCorp, download the executable or your system, and place it in the /usr/local/bin folder. While this is fairly simple to do, I have written a Bash script that’s part of the Build5Nines Terraform Quickstart Templates project to automate this for you.
You can use the following command to simultaneously download and execute the script to install the latest release version of HashiCorp Terraform to your local /usr/local/bin folder:
curl -s https://raw.githubusercontent.com/Build5Nines/terraform-quickstart-templates/main/terraform-tips/install/install-terraform.sh | bash
This script will check for the latest release version of Terraform to install. It will ignore any alpha, beta, or rc version, and instead only install the latest stable release.
If you’re interested in reading the bash code for this script, here’s the direct link to the script within the Build5Nines Terraform Quickstart Templates project: https://github.com/Build5Nines/terraform-quickstart-templates/blob/main/terraform-tips/install/install-terraform.sh
After you run the install script, and Terraform is installed, you can run Terraform just as you normally would.

Install Terraform on macOS using Homebrew
If you have Homebrew installed on macOS, then you can easily use Homebrew to install HashiCorp Terraform:
brew tap hashicorp/tap
brew install hashicorp/tap/terraform
You will likely have Homebrew installed if you’re using macOS. It’s a great package manager that really helps when installing all the various tools that DevOps Engineers and Site Reliability Engineers use on a daily basis.
Install Terraform on Linux
For Linux, there are several different package managers available depending on the Linux distribution you are using. When setting up Terraform deployment automation with your release automation process (with Azure DevOps Pipelines, Github Actions, or others) you may use the appropriate package manager for your system to install HashiCorp Terraform.
The most common Linux distribution you’ll probably be using is Ubuntu, so here’s the commands to use apt to install HashiCorp Terraform on Ubuntu Linux:
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install terraform
If you’re looking for help with using package managers to install HashiCorp Terraform on Linux, and you are choosing not to use my amazing install script (see above), then the Terraform documentation will be helpful.
Original Article Source: Terraform: Install Latest Version on macOS and Linux written by Chris Pietschmann (If you're reading this somewhere other than Build5Nines.com, it was republished without permission.)
Microsoft Azure Regions: Interactive Map of Global Datacenters
Create Azure Architecture Diagrams with Microsoft Visio
Stop Wasting Hours Writing Unit Tests: Use GitHub Copilot to Explode Code Coverage Fast
IPv4 Address CIDR Range Reference and Calculator
Retirement of AzureEdge.net DNS: Edg.io Business Closure and What You Need to Know




