01 Overview
Terraform reads HCL configuration and calculates a plan to create, update, or destroy cloud resources — VPCs, compute instances, DNS records, IAM policies — across dozens of providers, keeping actual and desired state in sync.
→ official documentation02 Installation
Pick a platform. Each step is copy-pasteable on its own.
01 Install prerequisites
sudo apt-get update && sudo apt-get install -y gnupg software-properties-common curl
02 Add the HashiCorp GPG key and repo
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/null 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
03 Install Terraform
sudo apt-get update && sudo apt-get install -y terraform
04 Verify
terraform -version
01 Add the HashiCorp repo
sudo dnf install -y dnf-plugins-core sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
02 Install Terraform
sudo dnf install -y terraform
03 Verify
terraform -version
01 Install via Homebrew
brew tap hashicorp/tap brew install hashicorp/tap/terraform
02 Verify
terraform -version
Note — commands assume sudo privileges and an up-to-date package index. Pin a specific version in production rather than tracking latest.
03 Install script
The steps above bundled into a single idempotent shell script for provisioning boxes unattended.
install-terraform.sh
Ubuntu/Debian target · safe to re-run · exits non-zero on failure
04 Cheatsheet
The commands reached for most often once Terraform is installed.
| Command | What it does |
|---|---|
| terraform init | Download providers and set up the backend |
| terraform plan | Preview changes before applying |
| terraform apply | Apply changes to reach the desired state |
| terraform destroy | Tear down everything the state manages |
| terraform fmt -recursive | Auto-format .tf files |
| terraform validate | Check configuration syntax |
| terraform state list | List resources tracked in state |
| terraform import addr id | Bring an existing resource under management |