asdf manage multiple version Terraform with GCP

Last update: 2022-08-03

We will use asdf as version manager with Terraform.


I will use Homebrew (Mac) + zsh to demonstrate.


## Installation
brew install asdf

## Add asdf to zshrc
echo -e "\n. $(brew --prefix asdf)/libexec/" >> ${ZDOTDIR:-~}/.zshrc

Install Terraform dependencies

asdf plugin-add terraform
asdf plugin-add terraform-ls

asdf install terraform 1.2.6
asdf global terraform 1.2.6

Install Google Cloud CLI

brew install --cask google-cloud-sdk
# or
curl | bash

Google Cloud CLI login

gcloud auth application-default login

Try to do terraform init and plan

# CD under project root directory

# Init terraform
terraform init

# Check changes
terraform plan