(Last Updated On: November 2, 2018)

Terraform is an Infrastructure as code tool which allows you to easily manage cloud resources in a versioned manner. You use Terraform to build, change, and version infrastructure deployed on popular service providers. This tool is not cloud-agnostic and it supports custom in-house solutions.

With Terraform you can manage Cloud Compute, Networking, Load Balancers, DNS and so on using simple Declarative Programming Language. See the complete list of Terraform Providers. Complex changesets can be applied to your infrastructure with minimal human interaction

How to Install Terraform on Ubuntu 18.04 LTS / CentOS 7

Terraform is distributed as a tarball on Github. Check the latest release on Terraform releases page before downloading below.

As of the writing of this article, the latest release is v0.11.8. Download it like below:

Ensure wget is installed

sudo apt-get install wget # Ubuntu
sudo yum install wget # CentOS

Then download the terraform archive.

export VER="0.11.10"
wget https://releases.hashicorp.com/terraform/${VER}/terraform_${VER}_linux_amd64.zip

Once downloaded, extract the archive:

$ sudo apt-get install unzip # Ubuntu
$ sudo yum install unzip     # CentOS 7
$ unzip terraform_${VER}_linux_amd64.zip
Archive:  terraform_0.11.10_linux_amd64.zip
  inflating: terraform

This will create a terraform binary file on your working directory. Move this file to the directory/usr/local/bin.

sudo mv terraform /usr/local/bin/

This will make the tool accessible to all user accounts.

$ which terraform

Confirm the version installed

$ terraform -v
Terraform v0.11.10

Verify that the tool works:

# terraform
Usage: terraform [-version] [-help] <command> [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

Next Steps

Now that you have Terraform installed, it is time to build infrastructure using a minimal Terraform configuration file. Terraform Use Cases is an interesting page to read.