install terraform on linux
Mar 12, 2025
Introduction
In this post I will cover installation of Hashicorp Terraform on my Linux box (Pop!_OS / Ubuntu). Terraform has a repository that can easily be added, making the process simple and familiar. In fact, it is the same as the Packer repository, so installation is super simple if you've followed the previous post.
Instructions at developer.hashicorp.com
Following the installation instructions provided at developer.hashicorp.com , the process is familiar for many packages. Be sure to select "Ubuntu/Debian" to follow along. As mentioned above, adding the key and repository (first two steps) are not necessary if you've followed the previous post about installing Packer. Keeping this in mind:
- First, add the HashiCorp GPGKey (might not be necessary)
$ wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
- Next, add the repository (might not be necessary)
$ echo "deb [arch=$(dpkg --print-architecture) 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
- Finally, update and install packer
$ sudo apt update
$ sudo apt install terraform
Verifying the installation
A simple verification of the installation can be had by checking the version and help:
$ terraform --version
Terraform v1.11.1
on linux_amd64
$ terraform --help
Usage: terraform [global options] <subcommand> [args]
The available commands for execution are listed below.
The primary workflow commands are given first, followed by
less common or more advanced commands.
Main commands:
init Prepare your working directory for other commands
validate Check whether the configuration is valid
plan Show changes required by the current configuration
apply Create or update infrastructure
destroy Destroy previously-created infrastructure
All other commands:
console Try Terraform expressions at an interactive command prompt
fmt Reformat your configuration in the standard style
force-unlock Release a stuck lock on the current workspace
get Install or upgrade remote Terraform modules
graph Generate a Graphviz graph of the steps in an operation
import Associate existing infrastructure with a Terraform resource
login Obtain and save credentials for a remote host
logout Remove locally-stored credentials for a remote host
metadata Metadata related commands
modules Show all declared modules in a working directory
output Show output values from your root module
providers Show the providers required for this configuration
refresh Update the state to match remote systems
show Show the current state or a saved plan
state Advanced state management
taint Mark a resource instance as not fully functional
test Execute integration tests for Terraform modules
untaint Remove the 'tainted' state from a resource instance
version Show the current Terraform version
workspace Workspace management
Global options (use these before the subcommand, if any):
-chdir=DIR Switch to a different working directory before executing the
given subcommand.
-help Show this help output, or the help for a specified subcommand.
-version An alias for the "version" subcommand.
Further information
That's it! All of the tools I need to start automating my infrastructure are in place. As previously stated, my goal is to use Terraform, Packer and Ansible to create digitalocean droplets, load balancers, SSL certificates, set up DNS, create firewalls etc in a way that is quick, easy repeatable, and scalable. Again, this is part of my attempt to implement Infrastructure as code (IaC) in my projects (even simple projects). If you'd like to follow along, check out the devops tag or infrastructure as code (IaC) tag .