How to Install Terraform on CentOS 7 Server

How to Install Terraform on CentOS 7 Server

 

Hashicorp Terraform is an opensource infrastructure as code DevOps tool. Using terraform you can write and create Infrastructure as code.

 

How to download Terraform

1. Log into your Linux server as ‘root’ user

2. You can download the latest version of terrafom from terraform.io website. Open the below download link in your web browser.

https://releases.hashicorp.com/terraform/

You can download zip file of the terraform stable version from the above website. Alpha and beta versions are also available in the above website.

3. Download the 32 bit / 64 bit package using ‘wget’ command

Command to download terraform zip file :
 

Download 32 bit :

 

# cd /usr/local/src
# wget https://releases.hashicorp.com/terraform/0.11.13/terraform_0.11.13_linux_386.zip


 

Download 64 bit:

 

# cd /usr/local/src
# https://releases.hashicorp.com/terraform/0.11.13/terraform_0.11.13_linux_amd64.zip


 

Always check the latest version in the terraform ‘download’ page before downloading:
 
https://www.terraform.io/downloads.html

4. Install terraform by unzipping the terraform zip archive it in your system path

 

# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

# unzip terraform_0.11.13_linux_amd64.zip -d /usr/local/bin
Archive: terraform_0.11.13_linux_amd64.zip
inflating: /usr/local/bin/terraform

 

5. After installing Terraform, you can verify that it is installed correctly by executing the command ‘terraform’ in your terminal.

 


# terraform
Usage: terraform [-version] [-help] [args]

The available commands for execution are listed below.
The most common, useful commands are shown first, followed by
less common or more advanced commands. If you're just getting
started with Terraform, stick with the common commands. For the
other commands, please read the help and docs before usage.

Common commands:
apply Builds or changes infrastructure
console Interactive console for Terraform interpolations
destroy Destroy Terraform-managed infrastructure
env Workspace management
fmt Rewrites config files to canonical format
get Download and install modules for the configuration
graph Create a visual graph of Terraform resources
import Import existing infrastructure into Terraform
init Initialize a Terraform working directory
output Read an output from a state file
plan Generate and show an execution plan
providers Prints a tree of the providers used in the configuration
push Upload this Terraform module to Atlas to run
refresh Update local state file against real resources
show Inspect Terraform state or plan
taint Manually mark a resource for recreation
untaint Manually unmark a resource as tainted
validate Validates the Terraform files
version Prints the Terraform version
workspace Workspace management

All other commands:
debug Debug output management (experimental)
force-unlock Manually unlock the terraform state
state Advanced state management