Terraform Switch (TFSwitch) for Mac & Linux

Not just any ordinary switch!

TFSwitch is a tool that can be downloaded on to Mac or Linux that allows you to switch between different Terraform versions fast and easily.

Terraform is a IaC tool which helps deploy infrastructure to the multiple cloud platforms. It is one of the most popular tools used to deploy services to the cloud and a very sort after skill which I believe is a must learn… (More blogs on this in the future)

I have been working with Terraform over the last couple years and it is a fantastic tool, but one issue that I have come across over time is whilst building a large infrastructure with Terraform you end up with a large amount of code, which leads to having a lot of different versions of Terraform code if it is not maintained.

For example code used to deploy an Application gateway may have used the latest version at the time v0.13 a month later an App service is deployed using the latest version of Terraform which is now v0.14 and so on…

As features change between different versions you would need to refactor your old code to perform an update with a newer version of Terraform, best coding practice is to update code to the latest version when you work on it but in some circumstances this is not possible.

Sooo…. you now have a sprawling amount on Terraform code which are on different versions, how do you make config changes to the old code? The obvious answer would be to install the Terraform version you need and point your PATH to this then revert once finished, but this is very convoluted and time consuming and is where TFSwitch comes to the rescue!

How does it work?

Once installed with one command “tfswitch” when in a directory with Terraform code it checks what version of Terraform is listed as required in your code and if you already have it installed in your system it will change to that version, if not it will ask you if you would like to download that version of Terraform for you to use.

If TFSwitch is unable to determine what version you need to use it will give you a list of available versions to use, if none of them are suitable you are able to download the one needed which it remembers.

This reduces the amount of time you spend changing Terraform versions manually and allows you to manage multiple versions of Terraform with ease.

I highly recommend this tool if you find yourself in the same situation.

For more information please checkout the website below

https://tfswitch.warrensbox.com/

Hope this has helped and if you have any questions or anything to add please do so ðŸ™‚