×
Community Blog Install Terraform in Three Simple Steps

Install Terraform in Three Simple Steps

In this blog, we'll show you how to download and install Terraform to take full advantage of its capabilities.

By Anthony Merrington, Technical Support Engineer at Alibaba Cloud

Terraform by HashiCorp is powerful infrastructure as code (IaC) tool that allows you to create, update, and control versioning of cloud infrastructure.

In the last blog, I discussed the incredible benefits of Terraform and how it can allow businesses to provision and manage cloud resources more efficiently than was previously possible. Now it's time to learn how to download and install Terraform so that you can begin to take advantage of its awesome capabilities.

Terraform is available in both an open source and enterprise version, and is fully integrated with all major cloud providers. Key use cases include performing orchestration on a large heterogeneous system that involves multi-cloud and hybrid cloud platforms, and scaling up and down the infrastructure according to variable online workloads.

1
Diagram detailing how Terraform can be used to manage infrastructure on Alibaba Cloud

There are three steps to completing the installation. After that, you'll be ready to plan your resources and deploy them at the click of a button.

Note that the following steps are taken from the related Best Practice document found on the Alibaba Cloud website. This tutorial walks you step-by-step through the procedure to set up Terraform and then use it to deploy cloud infrastructure. This is a great way to learn the basics of how to use Terraform. Although you'll need to register or log in to view the full document, the usefulness of it means it is well worth the effort.

Step 1: Download the Terraform installation package

When you download the installation package, select a version that suits your system configuration. In our example, we install Terraform 0.11.1 on a Mac OS 64-bit computer as an example. The steps to be performed on Linux are similar to the steps described here.

1) Visit the Terraform official website:

https://www.terraform.io/downloads.html

2) Select a version that suits your system configuration.

2

In this example, we click the download older versions of Terraform link and then select the 0.11.1 version.

3

Step 2: Install Terraform programs

1) Decompress the installation package.

2) Copy the binaries into a Terraform binary directory. We recommend that you copy the binaries into the /usr/local/bin directory so that you can avoid the configuration of environment variables.

Note: If you have copied the binaries into a different directory, for example, /usr/local/terraform, follow these steps to set environment variables:

a) Run the following command to change the directory:

cd ~ #

b) Run the following command to edit the bash_profile file:

open -e .bash_profile #

c) Add the following text to the end of the file:

export TERRAFORM_HOME=/usr/local/terraform
export PATH=$PATH:$TERRAFORM_HOME

d) Save the file and exit.

e) Run the following command for the changes to take effect:

source .bash_profile 

3) At a command prompt, run the terraform command to verify the installation of Terraform. The installation is successful if you receive a command result that resembles the following:

4

Step 3: Install the IDE

In this lab, we install IntelliJ IDEA as an example.

1) Install IntelliJ IDEA from the following website:

https://www.jetbrains.com/idea/download/

2) Install the Terraform plugin for IntelliJ IDEA. After you install the Terraform plugin, all files with a .tf extension are regarded as Terraform configuration files.

Next steps

Terraform is now installed and ready to use. Next, you can list out the resources that you plan to provision, create/modify the configuration code, and finally apply the Terraform configurations.

Learn more

Deepen your knowledge of Terraform by accessing the following free material:

0 0 0
Share on

ClouderLouder

9 posts | 4 followers

You may also like

Comments

ClouderLouder

9 posts | 4 followers

Related Products