Terraform
Install Terraform
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
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
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: