Home Infrastructure as Code (IaC) Installing Terraform on MacOS

Installing Terraform on MacOS

329
0

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.

  1. Visit Terraform’s official releases page.
  2. Download the macOS binary (darwin_amd64 for Intel, darwin_arm64 for Apple Silicon).
  3. Unzip it: unzip terraform_<version>_darwin_arm64.zip
  4. Move the binary to a directory in your PATH (e.g., /usr/local/bin): sudo mv terraform /usr/local/bin/
  5. 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

ProblemPossible Fix
terraform: command not foundMake sure /usr/local/bin or /opt/homebrew/bin is in your PATH. Run echo $PATH to confirm.
zsh: permission deniedRun installation or move commands with sudo.
Wrong version installedUse brew uninstall terraform and reinstall the correct version.
VS Code doesn’t detect TerraformReload 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:

  1. Installed or verified Homebrew
  2. Added the HashiCorp tap
  3. Installed Terraform via Homebrew
  4. Verified it with terraform -version

That’s it! 🎉 You now have Terraform ready on macOS to automate your infrastructure.

Previous articleInstalling Terraform on Linux (Ubuntu) and Windows (WSL2 with Ubuntu)
Next articleUnderstanding Terraform Core Concepts
Heartin Kanikathottu
As a seasoned Cloud and Security Architect, I’ve led transformative initiatives in key roles, including Vice President at Morgan Stanley, Principal Architect at Societe Generale, and Tech Lead & Cloud Security Architect at VMware, among others. I’m also an internationally published author with multiple books available on platforms like Amazon and O'Reilly. Notably, one of my books was recognized as the 8th best cloud computing book of all time in 2020, reflecting the impact of my contributions to the field. With over 15 professional certifications from providers such as Microsoft (Azure), Amazon (AWS), Oracle (Java), Pivotal (Spring), and IBM, I bring a wealth of expertise to my work. Academically, I hold dual Master’s degrees in Cloud Computing and Data Analytics. I’m passionate about sharing knowledge and mentoring others, which is why I actively speak at global technical forums such as Tech Opportunities Fest at Platform Calgary, Google's Kubernetes Meetup, Java User Group, Elasticsearch Meetup, and the Agile India Conference.

LEAVE A REPLY

Please enter your comment!
Please enter your name here