Terraform Installation and Setup
Terraform runs as a single binary file on your computer. There is no complex software to install. This topic walks you through downloading, installing, and verifying Terraform on all three major operating systems.
What You Need Before Installing
Terraform has no heavy prerequisites. You only need:
- A computer running Windows 10+, macOS 10.13+, or a modern Linux distribution
- Internet access to download Terraform and later communicate with cloud providers
- A terminal or command prompt application
You do not need to install a programming language, a runtime environment, or a package manager just to run Terraform.
Installing Terraform on macOS
The easiest way on macOS is through Homebrew, a popular package manager.
Step 1: Install Homebrew (if not already installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2: Install Terraform
brew tap hashicorp/tap brew install hashicorp/tap/terraform
Step 3: Verify the installation
terraform version
You see output like Terraform v1.9.0. The exact version number depends on when you install.
Installing Terraform on Windows
The fastest method on Windows is through the Chocolatey package manager or a manual download.
Method A: Using Chocolatey
choco install terraform
Method B: Manual Download
- Visit https://developer.hashicorp.com/terraform/downloads
- Download the Windows 64-bit zip file
- Unzip the file — you get a single file called
terraform.exe - Move
terraform.exeto a folder likeC:\terraform - Add that folder to your Windows PATH environment variable
Verify on Windows (in PowerShell or Command Prompt)
terraform version
Installing Terraform on Linux
For Ubuntu and Debian-based systems, use the official HashiCorp package repository.
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg 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 update && sudo apt install terraform
Verify on Linux
terraform version
Understanding the Terraform Binary
Terraform is just one file — the terraform binary. When you run Terraform commands, this single file does everything: reads your configuration files, calculates what changes to make, and talks to cloud provider APIs.
Diagram: Terraform Binary Role
Your .tf files Cloud Provider APIs
| ^
v |
[ terraform binary ] -------->|
| |
Reads config Sends API calls
Builds a plan Creates resources
Applies changes Returns results
Setting Up a Code Editor
You write Terraform code in plain text files. Any text editor works, but Visual Studio Code (VS Code) gives you the best experience because of the official HashiCorp Terraform extension.
Install the VS Code Terraform Extension
- Open VS Code
- Click the Extensions icon (the square icon in the left sidebar)
- Search for HashiCorp Terraform
- Click Install
This extension gives you syntax highlighting, auto-completion, and inline error messages as you type Terraform code.
Managing Multiple Terraform Versions with tfenv
Different projects sometimes require different Terraform versions. The tool tfenv lets you install and switch between versions easily.
# Install tfenv (macOS/Linux) git clone https://github.com/tfutils/tfenv.git ~/.tfenv # Install a specific Terraform version tfenv install 1.9.0 tfenv use 1.9.0
Teams that manage long-running projects use tfenv to make sure everyone runs the same Terraform version and avoids unexpected behavior from version differences.
Key Points
- Terraform installs as a single binary — no complex runtime or dependencies needed.
- Use Homebrew on macOS, Chocolatey on Windows, or the APT repository on Ubuntu/Debian.
- Always run
terraform versionafter installation to confirm it works. - VS Code with the HashiCorp extension is the recommended editor for writing Terraform code.
- Use tfenv when working on multiple projects that need different Terraform versions.
