We are going to use Homebrew to install Terraform.
First, let's add Hashicorp repo into the registry:
brew tap hashicorp/tap
And install terraform:
brew install hashicorp/tap/terraform
Check that terraform has been installed:
terraform -help
this should return the list of supported Terraform commands.
The installation part is now finished. Optionally, one may decide to install shell autocompletion package for Terraform:
touch ~/.zshrc
this will create shell config file if it does not exist.
Then install Terraform autocomplete:
terraform -install-autocomplete
Now, due to this defect, we have to manually add the following command to shell config:
autoload -Uz compinit && compinit
This line should be added before terraform autocompletion configuration. So edit your .zshrc file so that the last lines are like the following:
autoload -U +X bashcompinit && bashcompinit
autoload -Uz compinit && compinit
complete -o nospace -C /opt/homebrew/bin/terraform terraform