Step 1: Update and Install Required Packages
Ensure that your system is up to date and install the necessary packages:
sudo apt-get update && sudo apt-get install -y gnupg software-properties-common
Explanation:
apt-get update
: Updates the package list to the latest version.apt-get install -y gnupg software-properties-common
: Installs the required packages (gnupg
,software-properties-common
) needed for key management and repository addition.
Step 2: Install HashiCorp GPG Key
Use wget
to download HashiCorp's GPG key, dearmor it using gpg
, and save it as a keyring file:
wget -O- https://apt.releases.hashicorp.com/gpg | \
gpg --dearmor | \
sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
Explanation:
wget -O-
: Downloads the GPG key from the specified URL.gpg --dearmor
: Converts the GPG key to a binary format.tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
: Writes the binary key to the specified file.
Step 3: Verify the Key's Fingerprint
Verify the key's fingerprint using the gpg
command:
gpg --no-default-keyring \
--keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg \
--fingerprint
Explanation:
--no-default-keyring
: Prevents the use of the default keyring.--keyring
: Specifies the keyring file to use for this operation.
Step 4: Add HashiCorp Repository
Add the official HashiCorp repository to your system using the obtained key:
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
Explanation:
- Adds the HashiCorp repository information to the system's list of package sources.
Step 5: Download Package Information
Download the package information from the HashiCorp repository:
sudo apt update
Explanation:
- Updates the package information to include the HashiCorp repository.
Step 6: Install Terraform
Install Terraform from the HashiCorp repository:
sudo apt-get install terraform
Explanation:
- Installs Terraform from the newly added repository.
Step 7: Verify Installation
Verify that the installation was successful by checking Terraform's available subcommands:
terraform -help
Explanation:
- The
-help
option provides a list of available Terraform commands and usage information.
- The
Congratulations! You have now successfully installed Terraform on your Ubuntu/Debian system. Feel free to explore Terraform's capabilities by using various subcommands and refer to the official documentation for more details. ๐๐ป/