How to Install Terraform Locally on Unix, Windows, and Mac

Terraform is an open-source infrastructure-as-code tool developed by HashiCorp. It allows you to define and provision data center infrastructure using a clear, declarative configuration language. Installing Terraform on your local machine lets you efficiently manage your infrastructure directly. This guide explains how to install Terraform on Unix (Linux), Windows, and macOS systems.

Prerequisites

  • A stable internet connection
  • Basic knowledge of command line operations
  • Administrative or sudo privileges on your machine

Installation on Unix (Linux)

Step 1: Download Terraform

  • Visit the Terraform releases page.
  • Find the latest version suitable for your Linux distribution.
  • Copy the download link for the 64-bit Linux zip archive.

Alternatively, use wget or curl in the terminal:

wget https://releases.hashicorp.com/terraform/<VERSION>/terraform_<VERSION>_linux_amd64.zip

Replace <VERSION> with the latest version number, e.g., 1.5.7.

Step 2: Unzip the Terraform binary

unzip terraform_<VERSION>_linux_amd64.zip

Step 3: Move Terraform binary to a directory in your PATH

sudo mv terraform /usr/local/bin/

Step 4: Verify the installation

terraform -v

You should see the installed Terraform version.

Installation on Windows

Step 1: Download Terraform

Step 2: Extract the ZIP file

  • Right-click on the downloaded ZIP file and select “Extract All”.
  • Extract the terraform.exe file.

Step 3: Add Terraform to your system PATH

  • Move the terraform.exe file to a folder, e.g., C:\Terraform.
  • Add this folder to your system PATH:
  • Open Control Panel > System and Security > System > Advanced system settings.
  • Click Environment Variables.
  • Under System variables, find and select Path > Edit.
  • Click New, add C:\Terraform, and click OK to confirm.

Step 4: Verify installation

Open Command Prompt or PowerShell and run:

terraform -v

You should see the Terraform version printed.

Installation on MacOS

Step 1: Using Homebrew (recommended)

If you have Homebrew installed, installing Terraform is straightforward:

brew tap hashicorp/tap
brew install hashicorp/tap/terraform

Step 2: Verify installation

terraform -v

You should see the installed Terraform version.

Alternative: Manual installation

  • Download the MacOS 64-bit zip archive from the Terraform downloads page.
  • Unzip the archive.
  • Move the terraform binary to /usr/local/bin:
sudo mv terraform /usr/local/bin/
  • Verify the installation with terraform -v.

Additional Resources

Conclusion

Installing Terraform locally on Unix, Windows, or MacOS is straightforward and allows you to start managing your infrastructure as code immediately. Whether you prefer package managers like Homebrew or manual installation, following this guide will get you up and running quickly.

Happy Terraforming!


2 responses to “How to install terraform”

  1. Roxan Avatar
    Roxan

    The explanations are very clear and structured.

  2. Sylvester Avatar
    Sylvester

    This website is one of the best resources for learning terraform. The tutorials are simple and easy to follow. Highly recommended!

Leave a Reply

Your email address will not be published. Required fields are marked *