How to Install Terraform on macOS - Complete Step-by-Step Guide

Key Takeaway

Step-by-step guide to install Terraform on macOS. Install HashiCorp Terraform using brew, verify the installation, and configure your first project.

Table of Contents

Introduction

Terraform is the industry-standard Infrastructure as Code (IaC) tool for provisioning and managing cloud resources. This guide shows you how to install Terraform on macOS in under 5 minutes.

Apple Silicon (M1/M2/M3/M4) Support

Terraform fully supports Apple Silicon Macs. The Homebrew installation automatically detects your architecture and installs the correct binary (darwin_arm64).

🎓 Master Terraform — Complete Video Course

Learn Terraform from zero to hero with hands-on labs and real-world projects.

Start Learning →

Prerequisites

  • A macOS system (physical or virtual machine)
  • Administrator access
  • An active internet connection

Install Terraform on macOS

# Install Homebrew if not already installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install Terraform
brew tap hashicorp/tap
brew install hashicorp/tap/terraform

Verify the Installation

terraform -version

Expected output:

Terraform v1.12.x
on darwin_amd64

Enable Tab Completion

terraform -install-autocomplete
source ~/.bashrc

Alternative: Install from Binary

TERRAFORM_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | grep -oP '"current_version":"\K[^"]+')
wget "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_darwin_amd64.zip"
unzip "terraform_${TERRAFORM_VERSION}_darwin_amd64.zip"
sudo mv terraform /usr/local/bin/
terraform -version

Alternative: Install with tfenv

git clone --depth=1 https://github.com/tfutils/tfenv.git ~/.tfenv
echo 'export PATH="$HOME/.tfenv/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
tfenv install latest
tfenv use latest

Your First Terraform Project

mkdir ~/terraform-demo && cd ~/terraform-demo
cat > main.tf << 'EOF'
terraform {
  required_providers {
    local = {
      source  = "hashicorp/local"
      version = "~> 2.0"
    }
  }
}

resource "local_file" "hello" {
  content  = "Hello from Terraform on macOS!"
  filename = "${path.module}/hello.txt"
}
EOF

terraform init
terraform apply -auto-approve
cat hello.txt

Upgrade Terraform

brew upgrade hashicorp/tap/terraform

Uninstall Terraform

brew uninstall hashicorp/tap/terraform

Next Steps

🎓 Master Terraform — Complete Video Course

Learn Terraform from zero to hero with hands-on labs and real-world projects.

Start Learning →

Install Terraform on other platforms:

🚀

Level Up Your Terraform Skills

Hands-on courses, books, and resources from Luca Berton

Luca Berton
Written by

Luca Berton

DevOps Engineer, AWS Partner, Terraform expert, and author. Creator of Ansible Pilot, Terraform Pilot, and CopyPasteLearn.