Install Terraform 

Install Terraform
This tutorial explains the steps to install Terraform on macOS, Windows, Linux distributions, along with manual installations. 

 

Terraform is a free, open-source infrastructure as Code (IaC) software tool that users can use to build, change, and version infrastructures efficiently and securely. It can manage both popular and existing service providers and custom-build solutions.

Terraform helps produce a single execution plan explaining what it will do to reach the desired state after it runs to build the desired infrastructure. Terraform can determine what will change and build execution plans that can be used as configuration modifications.

The Terraform infrastructure could handle low-level elements like networking, computing, storage instances, and high-level elements, such as DNS entriesSaaS features, etc.

Users can host various manages of Terraform infrastructure over Google Cloud Platform, Amazon Web Services, Microsoft Azure, or on-prem within the private clouds like OpenStack, Apache CloudStack, or VMWare vSphere. Terraform can also provide support with multi-Cloud by having a single workflow for every Cloud. In this tutorial, we will learn the steps to install Terraform on macOS, Windows, Linux distributions, along with manual installations. 

 

Install Terraform on macOS X using Homebrew 

Homebrew is an open-source, free package management system for macOS X systems. In order to install the official Terraform formula from the terminal, follow the below steps:

1. First, install the HashiCorp tap (a repository of all the Homebrew packages) by executing the following command.

 

$ brew tap hashicorp/tap

 

2. Next, install Terraform by executing the following command:

 

$ brew install hashicorp/tap/terraform

 

>> Note: The above command will install a signed binary and automatically update with every new official release. 

 
Update Terraform to the Latest Version: 

In order to update Terraform to the latest version, follow the below steps: 

1. First, update the Homebrew repository by executing the following command: 

 

 $ brew update

 

2. Then, execute the below command to download and use the latest Terraform version:

 

 $ brew upgrade hashicorp/tap/terraform

 

 Sample Output: 

 ==> Upgrading 1 outdated package:hashicorp/tap/terraform 0.15.3 -> 1.0.0==> Upgrading hashicorp/tap/terraform 0.15.3 -> 1.0.0

 

Install Terraform on Windows using Chocolatey 

Chocolatey is a free, open-source package management system for Windows systems. In order to install the Terraform package from the command line, execute the following command:

 

$ choco install terraform

 

>> Note: HashiCorp does not directly maintain the Chocolatey and the Terraform packages. Users can always install the latest version of Terraform by using the manual installation method.

 

Manual Installation of Terraform 

In this process, we will retrieve the Terraform binary by compiling it from the source. In order to compile the Terraform binary, follow the below steps: 

1. First, clone the HashiCorp Terraform repository by executing the following command: 

 

 $ git clone https://github.com/hashicorp/terraform.git

 

2. Next, navigate to the newly created directory by executing the following: 

 

 $ cd terraform

 

3. Next, execute the following command to compile the Terraform binary and store it in the $USER/bin/terraform path: 

 

 $ go install

 

4. Finally, ensure that the Terraform binary is available on the user PATH. This process will differ depending on the user’s operating system.

 

macOS or Linux: 

1. In order to print the colon-separated list of locations in the user’s PATH by executing the following command: 

 

$ echo $PATH

 

2. Next, move the Terraform binary to one of the listed locations. The below command assumes that the binary is currently in their downloads folder and that the user’s PATH includes /usr/local/bin, but they can customize it if their locations are different.

 

$ mv ~/Downloads/terraform /usr/local/bin/

 

Windows

In order to ensure that the Terraform binary is available on the user PATH in Windows, follow the steps mentioned in the above Install Terraform on Windows using Chocolatey section.

 

Install Terraform on Linux Distributions

Terraform is a software tool created by HashiCorp, and it officially signs and maintains packages for the below Linux distributions.

 

Ubuntu/Debian: 

1. First, ensure that the user’s system is up to date and that they have the software-properties-common, GnuPG, and Curl packages installed. Users need these packages to verify HashiCorp’s GPG signature and install HashiCorp’s Ubuntu/Debian package repository. For the same, execute the following commands:  

 

$ sudo apt-get update
$ sudo apt-get install -y software-properties-common gnupg curl

 

2. Next, execute the following command to add the HashiCorp GPG key.

 

$ curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -

 

3. Add the official HashiCorp Linux repository by executing the following command: 

 

 $ sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"

 

4. Finally, execute the following commands to update the repository and install the Terraform command-line interface (CLI): 

 

$ sudo apt-get update 
$ sudo apt-get install terraform

 

RHEL/CentOS:

1. First, install yum-config-manager to manage the user’s repositories by executing the following command: 

 

$ sudo yum install -y yum-utils

 

2. Next, add the official HashiCorp Linux repository by using the following yum-config-manager command: 

 

$ sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo

 

3. Finally, execute the following command to install Terraform:

 

$ sudo yum -y install terraform

 

Fedora: 

1. First, install dnf config-manager to manage the user’s repositories by executing the following command: 

 

 $ sudo dnf install -y dnf-plugins-core

 

2. Next, add the official HashiCorp Linux repository by using the following command: 

 

$ sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/fedora/hashicorp.repo

 

3. Finally, execute the following command to install Terraform:

 

$ sudo dnf -y install terraform

 

Amazon Linux:

1. First, install yum-config-manager to manage the user’s repositories by executing the following command: 

 

 $ sudo yum install -y yum-utils

 

2. Next, add the official HashiCorp Linux repository by using the following command: 

 

$ sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo

 

3. Finally, execute the following command to install Terraform:

 

 $ sudo yum -y install terraform

 

Verify the Terraform Installation 

After the installation of Terraform, execute the following command to verify the installation: 

 

$ terraform -help

 

In order to learn more about what a sub-command does, add that particular sub-command along with the terraform -help command, as shown below: 

 

$ terraform -help plan

 

Conclusion 

This tutorial presents the steps to install Terraform on macOS, Windows, Linux distributions, along with manual installations. Hope this tutorial was helpful, and do reach out to us if you have any queries or suggestions.

 

Share this post

Services to Explore

Stay up to date!

Stay up to date with the Web Hosting, Cloud and Server Management Industry News and Tutorials!

We will send you only the relevant emails, and we respect your privacy. Please review our privacy policy for more info.

Terraform Consulting Services

Focus on your business, and let us work on your Terraform Projects!
From what you are reading, it seems you are interested in Terraform and related technologies. If you have a moment to spare, please take a look at our Terraform Consulting Services, which might interest you even more!
Terraform Consulting Services

Value-Added Services

We have services that can help you run a successful business. With us, you don't have to worry about these areas because our experts will take care of it for you.

ServerHealers uses cookies.