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.
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.
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.
In this example, we click the download older versions of Terraform link and then select the 0.11.1 version.
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:
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.
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:
Five Reasons Why Your Business Should Use Terraform to Deploy on the Cloud
9 posts | 4 followers
FollowAlibaba Clouder - September 10, 2020
ApsaraDB - August 30, 2021
Alibaba Clouder - April 21, 2020
Alibaba Clouder - July 2, 2020
Hieu Trong - September 20, 2023
Alibaba Clouder - August 9, 2018
9 posts | 4 followers
FollowAn enterprise-level continuous delivery tool.
Learn MoreRobotic Process Automation (RPA) allows you to automate repetitive tasks and integrate business rules and decisions into processes.
Learn MoreAccelerate software development and delivery by integrating DevOps with the cloud
Learn MoreAlibaba Cloud Function Compute is a fully-managed event-driven compute service. It allows you to focus on writing and uploading code without the need to manage infrastructure such as servers.
Learn MoreMore Posts by ClouderLouder