DEV Community

Antoine
Antoine

Posted on

Dev setup for Terraform for Linux on Windows

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!

Top comments (1)

Collapse
 
pauldevos7 profile image
Paul DeVos

This helps!!

I'm taking a new job where I am told I need to use a Windows laptop. I haven't used Windows in 8+ years and very much familiar with the zsh/terminal workflows and tooling for Terraform, Docker, Python package/env management and thus super dreading trying to do that on Windows as it was so difficult to install anything last I recalled.

But I heard about WSL and thus pretty excited about possibly setting up all that sort of tooling on various linux distros! So yeah, this helps :)