Dev setup for Terraform for Linux on Windows

antoinega profile image Antoine ・1 min read

My project use Terraform a lot.
But we use a Linux machine to deploy Terraform, and i use a Windows environment to develop and test new terraform files.

Terraform is compatible with both Windows and Linux, but we have to use Powershell script, and therefore specify in terraform which interpreter will receive the script.
It's Powershell.exe on Windows and pwsh on Linux.

We could have used Docker for providing a normalized environment (with a set Terraform version or a OS patch), to the cost of

  • a more complex tool to interact with, through the docker container
  • the Docker knowledge less spread among the team

The solution comes quite easily: use Windows Subsystem for Linux (WSL).

With WSL, we can

  • use an Ubuntu directly from Windows (Ubuntu 18.04)
  • have direct access to the same sources (no sync needed, the C:\ drive is mounted as /mnt/c/)
  • install Terraform, and Powershell Core without altering the Windows environment

Hope this helps!

Posted on by:

antoinega profile



mainly .Net but looking for great stuff about anything


markdown guide