Installing Terraform by script on Linux

The Linux Terraform installation script is as follows:

TERRAFORM_VERSION="0.12.8" #Update with your desired version

curl -Os https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip
&& curl -Os https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_SHA256SUMS
&& curl https://keybase.io/hashicorp/pgp_keys.asc | gpg --import
&& curl -Os https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_SHA256SUMS.sig
&& gpg --verify terraform_${TERRAFORM_VERSION}_SHA256SUMS.sig terraform_${TERRAFORM_VERSION}_SHA256SUMS
&& shasum -a 256 -c terraform_${TERRAFORM_VERSION}_SHA256SUMS 2>&1 | grep "${TERRAFORM_VERSION}_linux_amd64.zip:sOK"
&& unzip -o terraform_${TERRAFORM_VERSION}_linux_amd64.zip -d /usr/local/bin

This script does the following:

  • Set the TERRAFORM_VERSION parameter with the version to download.
  • Download the Terraform package by checking the checksum.
  • Unzip the package in the user local directory.
This script is also available in the GitHub source of this book: https://github.com/PacktPublishing/Learning_DevOps/blob/master/CHAP02/Terraform_install_Linux.sh.

For executing this script, follow these steps:

  1. Open a command-line Terminal.
  2. Copy and paste the preceding script.
  3. Execute it by hitting Enter in the command-line Terminal.

The following screenshot displays an execution of the script for installing Terraform on Linux:

In the execution of the preceding script, we can see the download of the Terraform ZIP package (with the curl tool) and the unzip operation of this package inside the /usr/local/bin folder.

We have just seen the installation of Terraform on Linux; now, let's look at its installation on Windows.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.62.103