Terraform is one of the most popular Infrastructure-as-Code (IaC) tools used by DevOps engineers and cloud architects. It allows you to define your cloud and on-premises infrastructure in code, making deployment repeatable, version-controlled, and consistent.
In this post, we’ll walk through how to install Terraform on macOS, whether you’re using an Intel-based Mac or the newer Apple Silicon (M1, M2, M3) models.
🧠 Why Terraform?
Terraform, developed by HashiCorp, uses a declarative configuration language to define and manage infrastructure resources.
Instead of manually creating servers, databases, or networks, you describe them in code and let Terraform handle the rest through commands like:
terraform init
terraform plan
terraform apply
Terraform automatically figures out what needs to change and applies it — safely and predictably.
Before you can do all that, let’s get it installed on your Mac.
⚙️ Installing Terraform on macOS
Terraform can be installed on macOS in a few ways, but the recommended and easiest is using Homebrew, the popular package manager for macOS.
Step 1: Verify Homebrew Installation
Check if you already have Homebrew installed:
brew --version
If you get a version number (for example, Homebrew 4.3.0), you’re good to go.
If not, install it using the following command (requires Xcode Command Line Tools):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Once installed, ensure your PATH includes Homebrew (especially for Apple Silicon Macs):
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
Step 2: Install Terraform via Homebrew
With Homebrew ready, installing Terraform is just one command away:
brew tap hashicorp/tap
brew install hashicorp/tap/terraform
This will download and install the latest stable version of Terraform from HashiCorp’s official tap.
Step 3: Verify Installation
Once installed, confirm Terraform is set up correctly by checking its version:
terraform -version
You should see something like:
Terraform v1.13.4
on darwin_arm64
(The version and architecture may differ based on your Mac model and the current release.)
💻 Alternative: Manual Installation (Optional)
If you prefer not to use Homebrew, you can install Terraform manually.
- Visit Terraform’s official releases page.
- Download the macOS binary (
darwin_amd64for Intel,darwin_arm64for Apple Silicon). - Unzip it:
unzip terraform_<version>_darwin_arm64.zip - Move the binary to a directory in your PATH (e.g.,
/usr/local/bin):sudo mv terraform /usr/local/bin/ - Verify installation:
terraform -version
This approach gives you full control over which version is installed, which can be helpful for testing or compatibility.
🔁 Updating Terraform
To upgrade to the latest version when using Homebrew:
brew update
brew upgrade hashicorp/tap/terraform
To remove Terraform entirely:
brew uninstall hashicorp/tap/terraform
🧰 Troubleshooting Common Issues
| Problem | Possible Fix |
|---|---|
terraform: command not found | Make sure /usr/local/bin or /opt/homebrew/bin is in your PATH. Run echo $PATH to confirm. |
zsh: permission denied | Run installation or move commands with sudo. |
| Wrong version installed | Use brew uninstall terraform and reinstall the correct version. |
| VS Code doesn’t detect Terraform | Reload VS Code or install the “HashiCorp Terraform” extension. |
🚀 Next Steps
Once Terraform is installed, you can:
- Configure a cloud provider (AWS, Azure, or GCP)
- Create your first configuration file
main.tf - Initialize your workspace:
terraform init - Preview and deploy:
terraform plan terraform apply
✅ Summary
Installing Terraform on macOS is quick and reliable — especially using Homebrew.
You:
- Installed or verified Homebrew
- Added the HashiCorp tap
- Installed Terraform via Homebrew
- Verified it with
terraform -version
That’s it! 🎉 You now have Terraform ready on macOS to automate your infrastructure.