Terraform Tutorial — Install Terraform on macOS & Windows
This page covers installing Terraform on macOS (using Homebrew) and Windows (using Chocolatey or manual download). If you’re on Windows and doing DevOps work, we also recommend WSL2.
macOS — Homebrew (Recommended)
If you have Homebrew installed, this is the fastest way to get Terraform:
$ brew tap hashicorp/tap
$ brew install hashicorp/tap/terraform
Verify the installation:
$ terraform version
Terraform v1.7.5
on darwin_arm64
To update later:
$ brew update
$ brew upgrade hashicorp/tap/terraform
💡 Tip: If you see
darwin_arm64, you’re on an Apple Silicon Mac (M1/M2/M3). If you seedarwin_amd64, you’re on an Intel Mac. Both are fully supported.
macOS — tfenv Alternative
Just like on Linux, you can use tfenv on macOS:
$ brew install tfenv
$ tfenv install 1.7.5
$ tfenv use 1.7.5
Windows — Chocolatey
Chocolatey is a package manager for Windows. If you have it installed:
> choco install terraform
Verify:
> terraform version
Terraform v1.7.5
on windows_amd64
Windows — Manual Installation
If you don’t use Chocolatey:
- Go to releases.hashicorp.com/terraform
- Download the Windows AMD64 zip file
- Extract
terraform.exefrom the zip - Move
terraform.exeto a directory on your PATH (e.g.,C:\terraform\) - Add that directory to your System PATH:
- Right-click “This PC” → Properties → Advanced System Settings → Environment Variables
- Under “System Variables”, find
Path, click Edit, addC:\terraform\
Verify in a new terminal:
> terraform version
Terraform v1.7.5
on windows_amd64
Windows — WSL2 (Recommended for DevOps Work)
Windows Subsystem for Linux 2 (WSL2) gives you a real Linux environment inside Windows. Most DevOps tools (Terraform, Ansible, Docker) work best on Linux, so WSL2 is the recommended setup for Windows users.
Install WSL2
> wsl --install
This installs Ubuntu by default. After restarting, you have a full Linux terminal.
Install Terraform in WSL2
Once inside WSL2, follow the Linux installation instructions:
$ sudo apt-get update && sudo apt-get install -y gnupg software-properties-common
$ 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
$ sudo apt-get update && sudo apt-get install terraform
💡 Tip: VS Code integrates beautifully with WSL2. Install the “Remote - WSL” extension, and you can edit files in WSL2 from the VS Code GUI.
Shell Completion
Enable tab completion for faster command entry:
Bash (Linux / WSL2 / macOS)
$ terraform -install-autocomplete
$ source ~/.bashrc
Zsh (macOS default)
$ terraform -install-autocomplete
$ source ~/.zshrc
After enabling, type terraform a and press Tab to see apply.
Verify Everything Works
Regardless of your OS, these commands should work:
$ terraform version
Terraform v1.7.5
on <your_platform>
$ terraform -help
Usage: terraform [global options] <subcommand> [args]
The available commands for execution are listed below.
...
If both commands produce output, you’re ready to move on.
What’s Next?
Terraform is installed. Now you need credentials so Terraform can talk to your cloud provider.