Monday 21 March 2022

How to install Terraform on Ubuntu

 Terraform provides binaries that can be downloaded from Linux binaries are pre-compiled for the following architectures: 
  • 386
  • Amd64
  • Arm
  • Arm64
To find out your architecture use: 

$ uname -m

This means we're running on Amd64 architecture and so the binary we'll download is where M.m.r is the latest version. This version can be extracted from Terraform git repository tag:
$ TER_VER=`curl -s | grep tag_name | cut -d: -f2 | tr -d \"\,\v | awk '{$1=$1};1'`
This is the latest Terraform version at the time of writing:

$ echo $TER_VER
We can use this variable in the following commands which download and unpack the archive and move the binary into bin directory accessible to all users on this machine:
$ wget${TER_VER}/terraform_${TER_VER}
$ unzip terraform_${TER_VER}
$ sudo mv terraform /usr/local/bin/

To test the installation:

$ terraform -v
Terraform v1.1.7
on linux_amd64

We can now delete the archive:
$ rm terraform_${TER_VER}



No comments: