What is Terraform?
Terraform is a popular cloud orchestration tool in the world of automation, which is used to deploy your infrastructure through the IAC (Infrastructure as code) approach. Terraform is built by Hashicorp and released under Mozilla Public License.
Supports:
- Public cloud
- Private cloud
- Hybrid cloud
Includes popular providers such as AWS, Azure cloud, GCP, Oracle cloud, and many others.
All you need is to download the terraform binary to your local/server machine which is going to act as your base machine.
Then Terraform will download the plugin for that particular provider automatically and will authenticate with provider API to execute the plan.
Infrastructure as Code
he process of provisioning and managing resources like Virtual Machine, Storage, Network, Database, etc.. through machine-readable definition files, rather than interactive tools or hardware configurations.
Features
- Open-source.
- Declarative syntax.
- Pluggable Modules.
- Immutable infrastructure.
- Simple client-only architecture.
Installing Terraform in Linux Distributions
The Terraform primary distribution packages come in .zip  format, which includes single executable files that you can decompress any location on your Linux system.
Install Terraform in RHEL, CentOS & Fedora
Method (1)
To install Terraform on CentOS, start by updating the repository lists:
sudo yum update
So You’ll need wget and unzip – if you don’t have them, install them by entering:
sudo yum install wget unzip
Download Terraform from the developer’s website:
sudo wget https://releases.hashicorp.com/terraform/1.0.0/terraform_1.0.0_linux_amd64.zip
Extract the downloaded file:
unzip ./terraform_1.0.0_linux_amd64.zip -d /usr/local/bin
The output confirms that the files are now located in the /usr/local/bin
 directory.
Lastly, verify that Terraform accepts commands:
terraform --version
The system should display Terraform v.1.0.0.
Note:
So To install the latest version from developers website visit this link and choose the latest:
By the way, the latest version right now is Terraform v1.0.0
Method (2)
However, for simpler integration with configuration management tools, terraform also offers package repositories for Debian-based and RHEL-based systems, which enables you to install Terraform using your default package management tools called APT and Yum.
All you have to do just follow the below commands :
$ sudo yum install -y yum-utils
$ sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/$release/hashicorp.repo
$ sudo yum update
$ sudo yum install terraform
Install Terraform in Debian, Ubuntu & Mint
Method (1)
So as the same as we did in CentOs we will follow the steps:
Before you download Terraform, update the repository lists:
sudo apt-get update
If your system does not have the wget and unzip utilities, use the following to install them:
sudo apt-get install wget unzip
So Run the wget utility to download Terraform:
sudo wget https://releases.hashicorp.com/terraform/1.0.0/terraform_1.0.0_linux_amd64.zip
So This is an example of the output:
Once the download finishes, extract the files:
sudo unzip ./terraform_1.0.0_linux_amd64.zip -d /usr/local/bin
Next, verify that Terraform accepts commands:
terraform version
Also The output should display Terraform v.1.0.0.
Method (2)
Also for simpler integration with configuration management tools, with package repositories follow these commands:
$ curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
$ sudo apt-add-repository "deb [arch=$(dpkg --print-architecture)] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
$ sudo apt update
$ sudo apt install terraform
Now the installation can be verified by running a simple terraform version command.
$ terraform --version