GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • .cls-1{fill:#fff;stroke-width:0}
  • Learn more
  • TerraformManage infrastructure as code
  • PackerBuild machine images
  • NomadOrchestrate workloads
  • WaypointStandardize application patterns
  • VagrantBuild developer environments
  • VaultCentrally manage secrets
  • BoundarySecure remote access
  • Vault RadarScan for embedded secrets
  • ConsulSecure network services
  • CertificationsGet HashiCorp certified
  • TutorialsLearn HashiCorp products
  • Sign up

This view

  • Original page
  • New address

GeezerVison is showing developer.hashicorp.com — Install Terraform | Terraform | HashiCorp Developer

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) <[email protected]>
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 system's 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.

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:

  • Amazon Web Services (AWS)
  • Microsoft Azure
  • Google Cloud Platform (GCP)
  • Oracle Cloud Infrastructure (OCI)
Previous

Infrastructure as Code

Next

Create

This tutorial also appears in:

  •  
    7 tutorials
    Get Started - OCI
    Build, change, and destroy a virtual cloud network and subnet on Oracle Cloud Infrastructure (OCI) using Terraform. Step-by-step, command-line tutorials will walk you through the Terraform basics for the first time.
    • Terraform
  •  
    7 tutorials
    Get Started - Google Cloud
    Build, change, and destroy Google Cloud Platform (GCP) infrastructure using Terraform. Step-by-step, command-line tutorials will walk you through the Terraform basics for the first time.
    • Terraform
  •  
    7 tutorials
    Get Started - Docker
    Build, change, and destroy Docker infrastructure using Terraform. Step-by-step, command-line tutorials will walk you through the Terraform basics for the first time.
    • Terraform
  •  
    8 tutorials
    Get Started - Azure
    Build, change, and destroy Azure infrastructure using Terraform. Step-by-step, command-line tutorials will walk you through the Terraform basics for the first time.
    • Terraform
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.