![Learning DevOps](https://wfqqreader-1252317822.image.myqcloud.com/cover/384/36698384/b_36698384.jpg)
上QQ阅读APP看书,第一时间看更新
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:
- Open a command-line Terminal.
- Copy and paste the preceding script.
- Execute it by hitting Enter in the command-line Terminal.
The following screenshot displays an execution of the script for installing Terraform on Linux:
![](https://epubservercos.yuewen.com/A085E6/19470376308796106/epubprivate/OEBPS/Images/6cc4a14b-29b6-4c80-8458-9265523b59b1.png?sign=1738890626-kwoL4EhA4KHmSoWc6TngD2AknC9eY6ES-0-a03e2ebd952428375223fac1a0e47319)
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.