Installing Terraform on CentOS

What is Terraform?

Zekiye AYDEMİR

--

Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform is an open source tool written in the Go programing language. Terraform can provision infrastructure across many different types of cloud providers, including Amazon Web Services(AWS), Azure, Google Cloud and many others. Testing and Production environments can easily be spun up and destroyed if necessary.

  • terraform init, basically initializes the working directory that contains your Terraform code. terraform init does is to download the supporting or ancillary components required for your code to work. These are things like the providers, which provide the libraries and code for your resources to be able to make API calls to whatever infrastructure you’re deploying into, and also modules. Terraform code is written in the HashiCorp Configuration Language (HCL) in files with the extension .tf. You can write Terraform code in just about any text editors.
  • terraform plan creates and shows you an execution plan for your infrastucture. By default, terraform plan looks within your current directory for config files and state files to refresh. Using terraform plan can allow you to see if your execution plan matches your expectations. You can do this without making any changes. This command does not deploy anything.
  • terraform apply, you are able to apply the changes to your infrastructure that is generated by the execution plan from terraform plan. By default, the first time you run terraform, terraform creates the terraform.tfstate file in the current directory. Every time you run Terraform, it saves information about what infrastructure it created in a terraform.tfstate file.

Installing Terraform

For CentOS/RHEL 7 :

yum install -y yum-utils
yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo

Then, install terraform:

yum install -y terraform

Check the Terraform version information:

Download And Manually Install the Terraform Binary

You can also download the terraform binary and execute it on your machine. The examples below are done on Linux Mint (Ubuntu flavour) for example.

Download the appropriate Terraform binary package for the Linux 64-bit using the wget command:

wget -c https://releases.hashicorp.com/terraform/1.1.9/terraform_1.1.9_linux_amd64.zip

Unzip the downloaded file:

unzip terraform_1.1.9_linux_amd64.zip

Place the Terraform binary in the PATH of the operating system so the binary is accessible system-wide to all users, then check the Terraform version information:

mv terraform /usr/local/bin/
terraform -v

In this article, I talked about terraform installation. For more detailed information, you can check the https://terraform.io website for up-to-date information.

--

--

Zekiye AYDEMİR

PostgreSQL Certified DBA | MongoDB Certified DBA | AWS Certified Admin