Book a 90-minute product workshop led by HashiCorp engineers and product experts during HashiConf Digital Reserve your spot

Get Started - Azure

Installing Terraform

HashiCorp Terraform is installed by default in the Azure Cloud Shell. Cloud shell can be run standalone, or as an integrated command-line terminal from the Azure portal.

We recommend that you use Cloud Shell and the Azure portal to complete this tutorial because it is the easiest way to get started using Terraform on Azure. Besides having latest release of Terraform already installed, Cloud Shell is configured to use your identity to authenticate to Azure. That simplifies the examples because it isn't necessary to include authentication credentials in the configuration.

If you choose not to use the Azure cloud Shell, you need to install Terraform on your target system. To install Terraform on any supported system:

  1. Find the appropriate Terraform distribution package for your system and download it. Terraform is distributed as a single .zip file.

  2. After downloading Terraform, unzip the package to a directory of your choosing. Terraform runs as a single binary named terraform. Any other files in the package can be safely removed and Terraform will still function.

  3. Optional but highly recommended: modify the path to include the directory that contains the Terraform binary.

    An alternative to modifying the path is to move the Terraform executable to a directory that is normally included in the path by default, for example: sudo mv terraform /user/local/bin

In addition to the basic installation just described, you also have the option to use a package manager to install Terraform:

»Compile from source

If you want to be certain that the terraform binary is from a trusted source, you can compile it yourself. This guide will not cover how to compile Terraform from source. The Terraform core and instructions are available from HashiCorp's GitHub repository.

»Verifying the installation

After installing Terraform, verify the installation by opening a new terminal session and checking that Terraform is available. Execute terraform at the prompt, and you should see output similar to this (truncated here for brevity):

$ terraform
Usage: terraform [-version] [-help] <command> [args]

The available commands for execution are listed below.
The most common, useful commands are shown first, followed by
less common or more advanced commands. If you're just getting
started with Terraform, stick with the common commands. For the
other commands, please read the help and docs before usage.

Common commands:
    apply              Builds or changes infrastructure
    console            Interactive console for Terraform interpolations
    destroy            Destroy Terraform-managed infrastructure

If you get an error that terraform could not be found, your PATH environment variable was not set up properly. Please go back and ensure that your PATH variable contains the directory where the Terraform binary was installed.