Terraform
CARVIEW |
Select Language
HTTP/2 200
age: 69586
cache-control: public, max-age=0, must-revalidate
content-encoding: gzip
content-type: text/html; charset=utf-8
date: Wed, 16 Jul 2025 21:34:58 GMT
etag: W/"ur9s5rb0m54wke"
server: Vercel
set-cookie: hc_geo=country%3DIN%2Cregion%3DKA; Path=/; Expires=Thu, 24 Jul 2025 16:54:45 GMT; Max-Age=604800
strict-transport-security: max-age=63072000
x-frame-options: SAMEORIGIN
x-matched-path: /[productSlug]/tutorials/[...tutorialSlug]
x-powered-by: Next.js
x-vercel-cache: HIT
x-vercel-id: bom1::sfo1::chlzn-1752771285663-f87c380324dd
Install Terraform | Terraform | HashiCorp Developer 
Install Terraform
- 7min
- |
- TerraformTerraform
- VideoVideo
- InteractiveInteractive
Terraform lets you safely and consistently manage your infrastructure as code across multiple cloud providers. To provision infrastructure with Terraform, you will write configuration in Terraform's configuration language, configure your cloud provider credentials, and apply your configuration with the Terraform Command Line Interface (CLI).
To use Terraform, you first need to install it. HashiCorp distributes Terraform as a binary package. You can also install Terraform using popular package managers.
Install Terraform
HashiCorp distributes Terraform as an executable CLI that you can install on supported operating systems, including Microsoft Windows, macOS, and several Linux distributions. You can also compile the Terraform CLI from source if a pre-compiled binary is not available for your system.
If you use a package manager to install software on your macOS, Windows, or Linux system, you can use it to install Terraform.
Homebrew is a free and open-source package management system for macOS. If you have Homebrew installed, use it to install Terraform from your command line.
First, install the HashiCorp tap, which is Hashicorp's official repository of all our Homebrew packages.
$ brew tap hashicorp/tap
Now, install Terraform from hashicorp/tap/terraform
.
$ brew install hashicorp/tap/terraform
Chocolatey is a free and open-source package management system for Windows. If you have Chocolatey installed, use it to install Terraform from your command line.
$ choco install terraform
Note
HashiCorp does not maintain Chocolatey or the Terraform package. The latest version of Terraform is always available for you to download and install manually. Refer to the Manual installation tab below for instructions.
HashiCorp maintains and signs packages for the following Linux distributions. Use the built-in package management system for your Linux distribution to install Terraform.
Ensure that your system is up to date and that you have installed the gnupg
and
software-properties-common
packages. You will use these packages
to verify HashiCorp's GPG signature and install HashiCorp's Debian package
repository.
$ sudo apt-get update && sudo apt-get install -y gnupg software-properties-common
Install HashiCorp's GPG key.
$ wget -O- https://apt.releases.hashicorp.com/gpg | \
gpg --dearmor | \
sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/null
Verify the GPG key's fingerprint.
$ gpg --no-default-keyring \
--keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg \
--fingerprint
The gpg
command reports the key fingerprint:
/usr/share/keyrings/hashicorp-archive-keyring.gpg
-------------------------------------------------
pub rsa4096 XXXX-XX-XX [SC]
AAAA AAAA AAAA AAAA
uid [ unknown] HashiCorp Security (HashiCorp Package Signing) <security+packaging@hashicorp.com>
sub rsa4096 XXXX-XX-XX [E]
Add the official HashiCorp repository to your system.
$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(grep -oP '(?<=UBUNTU_CODENAME=).*' /etc/os-release || lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
Update apt to download the package information from the HashiCorp repository.
$ sudo apt update
Install Terraform from the new repository.
$ sudo apt-get install terraform
Install yum-config-manager
to manage your repositories.
$ sudo yum install -y yum-utils
Use yum-config-manager
to add the official HashiCorp RHEL repository.
$ sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
Install Terraform from the new repository.
$ sudo yum -y install terraform
Install dnf config-manager
to manage your repositories.
$ sudo dnf install -y dnf-plugins-core
Use dnf config-manager
to add the official HashiCorp Fedora repository.
$ sudo dnf config-manager addrepo --from-repofile=https://rpm.releases.hashicorp.com/fedora/hashicorp.repo
Install Terraform from the new repository.
$ sudo dnf -y install terraform
Install yum-config-manager
to manage your repositories.
$ sudo yum install -y yum-utils
Use yum-config-manager
to add the official HashiCorp Amazon Linux repository.
$ sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo
Install Terraform from the new repository.
$ sudo yum -y install terraform
Install dnf config-manager
to manage your repositories.
$ sudo dnf install -y dnf-plugins-core
Use dnf config-manager
to add the official HashiCorp Amazon Linux repository.
$ sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo
Install Terraform from the new repository.
$ sudo dnf -y install terraform
Other Linux distributions may have pre-built Terraform packages available. Refer to your package manager's documentation, or follow the steps above for Manual installation.
Install the terraform
CLI by installing a pre-compiled executable or compiling
it from source.
To install Terraform, download the appropriate zip archive for your system and unzip it.
Terraform runs as a single executable named terraform
. Any other files in the archive can be safely removed and Terraform will still function.
To compile the Terraform executable from source, first clone the HashiCorp Terraform repository.
$ git clone https://github.com/hashicorp/terraform
Navigate to the new directory.
$ cd terraform
Next, compile the binary. The following command compiles the binary and stores
it in $GOPATH/bin/terraform
.
$ go install
Finally, make sure that the terraform
binary is available on your systems
PATH`. This process will differ depending on your operating system.
Print out a colon-separated list of locations in your PATH
.
$ echo $PATH
Move the Terraform executable to one of the listed locations. This command
assumes that the executable is currently in your downloads folder and that your
PATH
includes /usr/local/bin
. Customize it if your locations are different.
$ mv ~/Downloads/terraform /usr/local/bin/
For more detail about adding Terraform to your path, refer to your operating system's documentation.
Print out a semicolon-separated list of locations in your PATH
.
$ path
Move the Terraform executable to one of the listed locations.
$ move Downloads\terraform ...
For more details about adding binaries to your path, refer to the documentation for Windows.
Terraform versions and compatibility
HashiCorp regularly releases new versions of Terraform with new features and bug fixes. HashiCorp maintains compatibility between Terraform versions, so a Terraform configuration written for one version of Terraform should continue to work with any later minor version update. Refer to the Terraform compatibility promise for more details.
Verify the Installation
Verify that the installation worked by opening a new terminal session and listing Terraform's available subcommands.
$ terraform -help
Usage: terraform [global options] <subcommand> [args]
The available commands for execution are listed below.
The primary workflow commands are given first, followed by
less common or more advanced commands.
Main commands:
##...
Add -help
to any Terraform command to learn more about what it does and
available options.
$ terraform plan -help
Enable tab completion
If you use either Bash or Zsh as your command line shell, you can enable tab completion for Terraform commands. To enable autocomplete, first ensure that a configuration file exists for your chosen shell.
$ touch ~/.bashrc
$ touch ~/.zshrc
Then install the autocomplete package.
$ terraform -install-autocomplete
After installing autocomplete support, you will need to restart your shell to enable it.
Interactive terminal
You can learn how to install Terraform and create your infrastructure without setting up a cloud account in our interactive terminal.
Launch Terminal
This tutorial includes a free interactive command-line lab that lets you follow along on actual cloud infrastructure.
Next steps
Now that you have installed Terraform, you can use it to create and manage infrastructure with the cloud provider of your choice. Get started with one of the following providers: