Managing Multiple Terraform Versions with asdf
Terraform is updated frequently, and version differences tend to arise between projects, so being able to manage multiple versions makes operations smoother.
Why I recommend asdf
If all you need is to manage Terraform versions, tfenv is the popular choice.
However, since I also recommend adopting tflint and tfsec, asdf lets you manage versions of all these libraries using the same approach, which is why I recommend it.
Installing asdf on macOS
Reference: https://asdf-vm.com/guide/getting-started.html
1 | brew install asdf |
Adding the terraform plugin & installing multiple versions
1 | asdf plugin add terraform |
Specifying a version for a specific directory only
1 | cd path/to/terraform-project |
A .tool-versions file is generated, and the version is managed as follows.
1 | terraform 1.5.0 |
When a .tool-versions file is specified, that version will be used under that directory as long as it is installed.
tflint and tfsec can be managed with asdf in the same way
1 | $ asdf plugin add tflint |
I use this when I want to try out behavioral changes caused by version upgrades of tflint and tfsec locally.
That’s all.
I hope you find this helpful.
Managing Multiple Terraform Versions with asdf
https://kenzo0107.github.io/en/2023/07/08/install-terraform-multi-versions-by-asdf/
