Here’s a quick guide to installing HashiCorp Terraform on the three major platforms. Pick the one that matches your environment—or mix & match as needed!
1. macOS
A) Using Homebrew (recommended)
bash Copy code
brew tap hashicorp/tap
brew install hashicorp/tap/terraform
B) Manual Download
Visit https://www.terraform.io/downloads.html
Download the macOS 64-bit ZIP.
Unzip, then move the terraform binary into your PATH, e.g.:
bash Copy code
unzip terraform_*.zip
mv terraform /usr/local/bin/
2. Linux
A) Using a Package Manager
Debian/Ubuntu
bash Copy code
sudo apt-get update && \
sudo apt-get install -y gnupg software-properties-common curl
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update
sudo apt-get install terraform
RHEL/CentOS/Fedora
bash Copy code
sudo yum install -y yum-utils
sudo yum-config-manager \
--add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
sudo yum -y install terraform
Arch Linux
bash Copy code
pacman -Syu terraform
B) Manual Download
Download the Linux ZIP from https://www.terraform.io/downloads.html
Unzip and move it:
bash Copy code
unzip terraform_*_linux_amd64.zip
sudo mv terraform /usr/local/bin/
3. Windows
A) Using Chocolatey
Open an elevated PowerShell (Run as Administrator)
Install:
powershell Copy code
choco install terraform
B) Using Scoop
powershell Copy code
scoop install terraform
C) Manual Download
Download the Windows ZIP from https://www.terraform.io/downloads.html
Extract and place terraform.exe into a folder, e.g. C:\Terraform.
Add that folder to your System PATH :
Win+X → System → Advanced system settings → Environment Variables
Under “System variables” find Path → Edit → New → C:\Terraform
4. Verify Installation
In your terminal or PowerShell, run:
bash Copy code
terraform version
You should see output like:
code Copy code
Terraform v1.5.2
5. (Optional) Manage Multiple Versions with tfenv
If you need to switch between Terraform versions, consider using tfenv :
bash Copy code
# macOS / Linux
git clone https://github.com/tfutils/tfenv.git ~/.tfenv
export PATH="$HOME/.tfenv/bin:$PATH"
tfenv install 1.5.2
tfenv use 1.5.2
That’s it! 🎉 You now have Terraform installed and ready to go.
Need help writing your first .tf file or initializing a project? Just let me know!