Installing Terraform on Windows, Linux & macOS

Published: 2025-07-23
7 min read
Share:

Installing Terraform is the first step toward managing infrastructure with code. Whether you're deploying resources on AWS, Azure, Google Cloud, or an on-premises environment, Terraform provides a consistent way to define, provision, and manage infrastructure.

The Terraform installation steps are straightforward and usually take only a few minutes. Once Terraform is installed, you'll be ready to create infrastructure using reusable, version-controlled configuration files.

What Is Terraform and Why Do You Need to Install It?

Terraform is an Infrastructure as Code (IaC) tool developed by HashiCorp. It allows you to define infrastructure using configuration files written in HashiCorp Configuration Language (HCL).

Instead of manually creating resources through cloud consoles, you describe the desired state of your infrastructure in code. Terraform then creates, updates, or removes resources as needed.

In many DevOps and platform engineering teams, Terraform is one of the first tools engineers learn because infrastructure changes can be reviewed, tested, version-controlled, and automated just like application code.

If you're new to Terraform syntax, start with our guide on HCL Basics before building larger projects.

Installing Terraform on Windows

Follow these steps to install Terraform on Windows:

  1. Visit the official Terraform installation page:

    • https://developer.hashicorp.com/terraform/install
  2. Download the latest Windows AMD64 package.

  3. Extract the ZIP archive.

  4. Move terraform.exe to a permanent directory such as:

C:\Terraform
  1. Add the directory to your Windows PATH environment variable.

  2. Open Command Prompt or PowerShell and verify the installation:

terraform version

You should see the installed Terraform version displayed.

Common Issue: If you receive a message such as 'terraform' is not recognized as an internal or external command, the Terraform binary location is usually missing from your PATH environment variable.

Installing Terraform on macOS

Terraform can be installed manually or through Homebrew.

If Homebrew is already installed on your system:

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

Verify the installation:

terraform version

To upgrade Terraform later:

brew upgrade terraform

Manual Installation on macOS

  1. Download the latest macOS package from the official Terraform installation page.
  2. Extract the archive.
  3. Move the Terraform binary to:
/usr/local/bin
  1. Verify the installation:
terraform version

Installing Terraform on Linux

HashiCorp recommends using the official package repository because it simplifies updates and version management.

Install Terraform on Ubuntu or Debian

First, install required packages:

sudo apt-get update
sudo apt-get install -y gnupg software-properties-common curl

Add the HashiCorp GPG key:

wget -O- https://apt.releases.hashicorp.com/gpg | \
gpg --dearmor | \
sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/null

Add the official HashiCorp repository:

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

Install Terraform:

sudo apt-get update
sudo apt-get install terraform

Verify the installation:

terraform version

Install Terraform on Other Linux Distributions

HashiCorp provides installation instructions for Red Hat, Fedora, Amazon Linux, Arch Linux, and other distributions:

https://developer.hashicorp.com/terraform/install

Verify That Terraform Is Working Correctly

After installing Terraform, run:

terraform version

A successful response confirms that Terraform is correctly installed and available in your PATH.

You can also check available commands:

terraform -help

This displays the complete command reference supported by your installed version.

Pro Tip: Many organizations pin Terraform versions to avoid unexpected behavior during upgrades. As you move into larger projects, learn how to manage version constraints in Terraform for consistent deployments across teams.

First Steps After Installing Terraform

Once Terraform is installed, create a working directory for your configuration files.

Terraform configurations use the .tf extension and describe the infrastructure resources you want Terraform to manage.

Here's a simple example:

resource "random_pet" "my_pet" {
  length    = 2
  separator = "-"
}

This resource uses the Random provider to generate a random name.

Providers are plugins that allow Terraform to interact with external platforms. Learn more in our guide on using Terraform providers.

Before using the example above, initialize your project:

terraform init

Terraform will automatically download the required provider plugins.

A Typical Terraform Workflow

Most Terraform projects follow this workflow:

  1. Install Terraform
  2. Create configuration files
  3. Run terraform init
  4. Review changes with terraform plan
  5. Apply changes with terraform apply
  6. Update infrastructure as requirements change

If you're unfamiliar with these commands, read our detailed guide on Terraform Commands Explained.

After learning the basics, continue with our tutorial on Getting Started with Terraform and AWS to deploy real cloud infrastructure.

Understanding Terraform Resources with Practical Examples

A Terraform resource represents any infrastructure object that Terraform can manage.

Examples include:

  • AWS EC2 instances
  • AWS S3 buckets
  • Azure SQL Databases
  • Google Cloud App Engine services
  • IAM users and roles
  • Local files and directories

For example:

  • An EC2 instance can be defined in code instead of being created manually through the AWS console.
  • An S3 bucket can be version-controlled and recreated consistently across environments.
  • IAM roles can be standardized across multiple AWS accounts.

If you're interested in real-world examples, explore:

Terraform supports hundreds of providers available through the official Terraform Registry.

Why Learning Terraform Matters

Infrastructure environments continue to grow in complexity. Managing resources manually becomes difficult, error-prone, and inconsistent.

Terraform helps teams:

  • Automate infrastructure deployments
  • Track changes through version control
  • Reuse infrastructure patterns
  • Standardize environments
  • Reduce manual configuration errors

If you're new to Infrastructure as Code, you may also want to read:

Conclusion

Installing Terraform typically takes only a few minutes, but it provides the foundation for managing infrastructure in a repeatable and automated way.

Once Terraform is installed and verified, you can start creating configuration files, working with providers, managing resources, and deploying infrastructure across multiple cloud platforms.

Start with simple examples, learn the core commands, and gradually move into real-world projects. The skills you build now will carry directly into DevOps, cloud engineering, platform engineering, and Site Reliability Engineering workflows.

FAQ — Installing Terraform

Q1: Is Terraform free to use?

Yes. Terraform Community Edition is open source and free to use. HashiCorp also provides commercial offerings for larger organizations.

Q2: Can I use Terraform on Windows, Linux, and macOS?

Yes. Terraform officially supports Windows, macOS, and major Linux distributions.

Q3: Do I need any dependencies before installing Terraform?

Terraform itself is distributed as a standalone binary. Some installation methods may require package management tools such as Homebrew or APT.

Q4: How do I uninstall Terraform?

Remove the Terraform binary from your system and delete any related PATH entries if applicable.

Q5: What editor should I use for Terraform files?

Popular options include:

  • Visual Studio Code
  • Vim
  • Neovim
  • IntelliJ IDEA
  • Sublime Text

Visual Studio Code is commonly used because of its Terraform extensions and syntax support.

Q6: What should I learn after installing Terraform?

A recommended learning path is:

  1. HCL Basics
  2. Terraform Commands
  3. Providers
  4. Variables
  5. Resources
  6. Modules
  7. State Management
  8. Cloud Deployments

You can begin with Getting Started with Terraform and AWS after completing the installation.

Free Engineering ToolsNEW

8 free, 100% client-side tools for developers — no signup, no data uploads.

Explore all tools