Brew Terraform

admin

Terraform v0.11.14 The brew pin command will prevent Homebrew from updating/upgrading your version of Terraform when you run the brew upgrade command. I would strongly suggest pinning Terraform because otherwise, the brew upgrade command will remove all older versions of Terraform from your system. $ brew pin terraform. Use asdf to switch terraform versions. Asdf-vm or asdf is a CLI tool that manages multiple language runtime versions on a per-project basis. It’s like gvm, nvm, rbenv, and pyenv and more. This post shows you how to install and configure multiple versions of terraform using asdf. I used brew on OSX to install asdf in a bash shell. On macOS, run brew install terraform if you don’t have it already and check your setup with: $ terraform version Terraform v0.14.2 And that’s all the preparation that is needed. Create a file terraform. Terraform by Hashicorp is a utility that creates simple to complex infrastructure on-prem or in the cloud. Terraform is a single binary file that reads configuration files, creates a state and then ensures your infrastructure is creating and remains in that state.

Use asdf to switch terraform versions

asdf-vm or asdf is a CLI tool that manages multiple language runtime versions on a per-project basis. It’s like gvm, nvm, rbenv, and pyenv and more.

Purpose

This post shows you how to install and configure multiple versions of terraform using asdf. I used brew on OSX to install asdf in a bash shell. There are also instructions to install with git using linux bash, ZSH, and fish on Getting Started with asdf-vim.

Procedure

Install asdf with brew

Successful output includes

Test for a successful instal using the asdf version command

Successful output includes a version number like this

Configure your shell to use asdf using your .bash_profile

To test, cat your ~/.bash_profile and filter for asdf. You should see this output from the cat command

Test your ASDF_DIR and PATH is set properly env and filtering for asdf. You should see an ASDF_DIR entry as well as a PATH entry that includes /.asdf/shims

Install dependencies for plugins

Successful output from brew includes a Summary and a Pouring for each dependency. This shows output for libxml

Now, we have asdf installed and configured in our shell, and we’ll install the terraform plugin and manage between v.0.11 and v.0.12.

Install Terraform plugin for asdf

Successful output includes Cloning from the reop and Unpacking the objects

List versions of terraform

Successful output includes a list versions like this

We chose to install the latest version at the time of this writing, 0.12.5 as well as the latest version of terraform 0.11; which is 0.11.14

Install the latest v 0.11.x terraform using asdf

expected output includes Macos standalone updater.

Install the latest v 0.12.x terraform using asdf

expected output includes

Set the global terraform version to 0.12.5

there is NO expected output from this command. test with the terraform --verison command

expected output includes a terraform version number

Test the current version of terraform using asdf

expected output includes a terraform version

Switch to the older version of terraform using asdf to set the global version pf asdf

Brew Terraform

expected output includes a terraform version number

Brew Install Terraform

Brew Terraform

Test the current version of terraform using asdf

expected output includes a terraform version

Brew Terraform Update

You have now installed asdf, added the plugin for terraform, installed two different versions of terraform, and you can switch between those versions using the asdf global command. Nice work.