Update the system first:
apt update -y && apt upgrade -y''\\
apt-get install wget curl unzip software-properties-common gnupg2 -y
# OLD, do not use: curl -fsSL https://apt.releases.hashicorp.com/gpg > /etc/apt/trusted.gpg.d/hashicorp.gpg
curl -fsSL https://apt.releases.hashicorp.com/gpg | gpg --dearmor > /etc/apt/trusted.gpg.d/hashicorp.gpg
apt-add-repository "deb [arch=$(dpkg --print-architecture)] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
apt update -y
apt-get install terraform -y
terraform -v
Terraform v1.1.7
on linux_amd64