tftools - PowerShell module for Terraform version handling

One of the great things with PowerShell is that it’s pretty easy to create your own tools. Due to the nature of Terraform, there are times where you need a specific version of Terraform. For instance, a client that I work at these days have some old code written in 0.11 while also creating new code that uses 0.12 syntax. This can easily happen if you have a big code base, as it’s almost impossible at times to update the entire thing.

While there are other solutions for version handling, these were either platform specific or did not have all the functionality that I wanted. So, I wanted to make a PowerShell module to completely handle Terraform versioning on every platform. Not everyone uses the new open source PowerShell either (shame…) so it needs to work on Windows PowerShell.

Happy to announce that for Windows and Linux, I have a functional version. I got a Mac laying around that I will be the guinea pig to get Mac support as well.

edit: As of version 0.3.5, the module now also supports MacOS. Read more about 0.3.5 here.

The module can do the following:

  • Install the version of Terraform that you want, or the latest version
  • Change between version of Terraform
  • List all versions of Terraform that you have installed in you “library”
  • Delete versions of Terraform

I named it tftools, so that I can expand the feature set if I ever felt like it. For now, having a way to switch between versions of Terraform really helps my workflow and I’m sure this will help others as well.

Installation

If you already have Terraform installed by any other means, you want to remove that before installing

Installation is pretty simple. The module is published on powershellgallery, so all you need to do is the following.

Install-Module -Name tftools

Updating the module:

Update-Module -Name tftools

Staying up to date

To keep up to date with this module, you can star the repository at GitHub or follow me on twitter.

Roberth Strand's Picture

About Roberth Strand

Cloud consultant working primarily with Microsoft Azure, automation and infrastructure.

Tromsø, Norway https://robstr.dev

Comments