AMP AMP

How to install Terraform on Debian 12

To Install Terraform On Debian 12

Introduction:

Terraform is a program used to build infrastructure automatically—without accessing a cloud provider's console. Terraform can automatically build, update, and destroy infrastructure. It can create various resources: virtual machines, users, network devices, and security components. It enables a person to work with multiple cloud providers (AWS, Azure, Google, etc...) and on-premises systems (VMware, KVM, Proxmox) and much more.

Installation Steps:

Step 1: Check the OS version by using the below command.

root@linuxhelp:~# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Step 2: Download the GPG key for install Terraform by using the below command.

root@linuxhelp:~# wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
--2024-04-23 04:32:58--  https://apt.releases.hashicorp.com/gpg
Resolving apt.releases.hashicorp.com (apt.releases.hashicorp.com)... 18.161.229.117, 18.161.229.45, 18.161.229.91, ...
Connecting to apt.releases.hashicorp.com (apt.releases.hashicorp.com)|18.161.229.117|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3980 (3.9K) [binary/octet-stream]
Saving to: ‘STDOUT’

-                                  100%[================================================================>]   3.89K  --.-KB/s    in 0s      

2024-04-23 04:32:58 (11.5 MB/s) - written to stdout [3980/3980]

Step 3: Add the GPG key by using the below command.

root@linuxhelp:~# echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com bookworm main

Step 4: Update the System Packages by using the below command.

root@linuxhelp:~# apt update
Get:1 https://apt.releases.hashicorp.com bookworm InRelease [12.9 kB]
Get:2 http://security.debian.org/debian-security bookworm-security InRelease [48.0 kB]                         
Get:3 http://deb.debian.org/debian bookworm InRelease [151 kB]
Get:4 https://apt.releases.hashicorp.com bookworm/main amd64 Packages [127 kB]
Get:5 http://deb.debian.org/debian bookworm-updates InRelease [55.4 kB]
Get:6 http://security.debian.org/debian-security bookworm-security/main Sources [91.4 kB]
Get:7 http://security.debian.org/debian-security bookworm-security/main amd64 Packages [155 kB]
Get:8 http://security.debian.org/debian-security bookworm-security/main Translation-en [94.3 kB]
Get:9 http://deb.debian.org/debian bookworm/main Sources [9,489 kB]
Get:10 http://deb.debian.org/debian bookworm/main amd64 Packages [8,786 kB]
Get:11 http://deb.debian.org/debian bookworm/main Translation-en [6,109 kB]
Get:12 http://deb.debian.org/debian bookworm-updates/non-free-firmware Sources [2,076 B]
Get:13 http://deb.debian.org/debian bookworm-updates/non-free-firmware amd64 Packages [616 B]
Get:14 http://deb.debian.org/debian bookworm-updates/non-free-firmware Translation-en [384 B]
Fetched 25.1 MB in 4s (6,246 kB/s)                        
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
96 packages can be upgraded. Run 'apt list --upgradable' to see them.
N: Repository 'http://deb.debian.org/debian bookworm InRelease' changed its 'Version' value from '12.4' to '12.5'

Step 5: Install the Terraform by using the below command.

root@linuxhelp:~# apt install terraform -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  git git-man liberror-perl
Suggested packages:
  git-daemon-run | git-daemon-sysvinit git-doc git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
  git git-man liberror-perl terraform
0 upgraded, 4 newly installed, 0 to remove and 96 not upgraded.
Need to get 36.8 MB of archives.
After this operation, 136 MB of additional disk space will be used.
Get:1 https://apt.releases.hashicorp.com bookworm/main amd64 terraform amd64 1.8.1-1 [27.6 MB]
Get:2 http://deb.debian.org/debian bookworm/main amd64 liberror-perl all 0.17029-2 [29.0 kB]
Get:3 http://deb.debian.org/debian bookworm/main amd64 git-man all 1:2.39.2-1.1 [2,049 kB]
Get:4 http://deb.debian.org/debian bookworm/main amd64 git amd64 1:2.39.2-1.1 [7,171 kB]
Fetched 36.8 MB in 5s (7,593 kB/s)
Selecting previously unselected package liberror-perl.
(Reading database ... 169305 files and directories currently installed.)
Preparing to unpack .../liberror-perl_0.17029-2_all.deb ...
Unpacking liberror-perl (0.17029-2) ...
Selecting previously unselected package git-man.
Preparing to unpack .../git-man_1%3a2.39.2-1.1_all.deb ...
Unpacking git-man (1:2.39.2-1.1) ...
Selecting previously unselected package git.
Preparing to unpack .../git_1%3a2.39.2-1.1_amd64.deb ...
Unpacking git (1:2.39.2-1.1) ...
Selecting previously unselected package terraform.
Preparing to unpack .../terraform_1.8.1-1_amd64.deb ...
Unpacking terraform (1.8.1-1) ...
Setting up liberror-perl (0.17029-2) ...
Setting up git-man (1:2.39.2-1.1) ...
Setting up git (1:2.39.2-1.1) ...
Setting up terraform (1.8.1-1) ...
Processing triggers for man-db (2.11.2-2) ...

Step 6: Check the Terraform version by using the below command.

root@linuxhelp:~# terraform version
Terraform v1.8.1
on linux_amd64

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to install Terraform on Debian 12. Your feedback is much welcome.

FAQ
Q
What is Terraform init?
A
Terraform init is a control to initialize an operational index that contains Terraform pattern files. This control can be looped multiple times. It is the first command that should be run after writing the new Terraform design.
Q
Are callbacks possible with Terraform on Azure?
A
By using the Azure Event Hubs, callbacks are probable on Azure. Terraform’s Azure supplier provides effortless functionality to users. Microsoft Azure Cloud Shell provides an already installed Terraform occurrence.
Q
What are the most useful Terraform commands?
A
Some of the most useful Terraform commands are:
terraform init - initializes the current directory
terraform refresh - refreshes the state file
terraform output - views Terraform outputs
terraform apply - applies the Terraform code and builds stuff
terraform destroy - destroys what has been built by Terraform
terraform graph - creates a DOT-formatted graph
terraform plan - a dry run to see what Terraform will do
Q
What are the key features of Terraform?
A
Terraform helps you manage all of your infrastructures as code and construct it as and when needed. Here are its key main features:
A console that allows users to observe functions
The ability to translate HCL code into JSON format
A configuration language that supports interpolation
A module count that keeps track of the number of modules applied to the infrastructure.
Q
What do you understand by Terraform in AWS?
A
Terraform is a part of the AWS DevOps Competency and also an AWS Partner Network (APN) advanced technology partner. It is similar to AWS Cloud Formation in the sense that it is also an “infrastructure as code” tool that allows you to create, update, and version your AWS infrastructure.