Terraform Tutorial — Install Terraform on macOS & Windows

2 minute read

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.


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 see darwin_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:

  1. Go to releases.hashicorp.com/terraform
  2. Download the Windows AMD64 zip file
  3. Extract terraform.exe from the zip
  4. Move terraform.exe to a directory on your PATH (e.g., C:\terraform\)
  5. Add that directory to your System PATH:
    • Right-click “This PC” → Properties → Advanced System Settings → Environment Variables
    • Under “System Variables”, find Path, click Edit, add C:\terraform\

Verify in a new terminal:

> terraform version
Terraform v1.7.5
on windows_amd64

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.


← Install on Linux Setting Up Cloud Credentials →