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.
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:
2) Select a version that suits your system configuration.
In this example, we click the download older versions of Terraform link and then select the 0.11.1 version.
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:
d) Save the file and exit.
e) Run the following command for the changes to take effect:
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:
Step 3: Install the IDE
In this lab, we install IntelliJ IDEA as an example.
1) Install IntelliJ IDEA from the following website:
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.
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.
Deepen your knowledge of Terraform by accessing the following free material:
- Best Practice: tutorial for beginners that teaches you step-by-step how to deploy cloud infrastructure by using Terraform (free): https://resource.alibabacloud.com/bestpractice/detail.html?&bpId=2020052213432000000
- Related Alibaba Cloud Academy course (free): https://edu.alibabacloud.com/course/212