Skip to main content

Command Palette

Search for a command to run...

What is Terraform?

Updated
2 min read

Terraform is an open-source Infrastructure as Code (IaC) tool that lets developers provision and manage the cloud or on-prem resources through machine-readable declarative configuration files. HashiCorp created it.

Traditionally, suppose one wants to provision/launch, for example, an EC2 instance. In that case, one should log in to the AWS Console, navigate to the EC2 service, and click the launch instance button followed by a series of interactive processes (multiple clicks). Imagine going through these manual steps when launching several instances. This is a time-consuming and tedious process. The solution is using Terraform.

Terraform is a declarative language. We tell it what we want not how to do. We write the code defining our requirements and execute it with Terraform. Boom! Terraform provisions the resources mentioned in the code. For this, we need to have Terraform installed on our machine.

Installing Terraform

We can install Terraform either by using a package manager or by downloading the binary and setting the path (optional).

Let’s see both of them in action on a Linux system.

OS-Distro: Linux-CentOS/RHEL

  • Using a package manager,

      sudo yum install -y yum-utils
      sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
      sudo yum -y install terraform
    
  • Downloading the binary,

    curl -s -qL -o terraform.zip https://releases.hashicorp.com/terraform/{TF_VERSION}/terraform_{TF_VERSION}_linux_amd64.zip

      sudo curl -s -qL -o terraform.zip https://releases.hashicorp.com/terraform/1.10.1/terraform_1.10.1_linux_amd64.zip
      sudo unzip -o terraform.zip
      sudo mv terraform /bin
      sudo rm terraform.zip
    

    Moving the Terraform binary file to the /bin directory lets us run the Terraform command globally.

  • Verify the installation by checking the version,

    terraform version or terraform -version or terraform —version

      sudo terraform version
    

That’s a brief and simple introduction to Terraform.

Happy learning!

Terraform

Part 1 of 1

This series contains everything about the Terraform.