Dev setup for Terraform for Linux on Windows

Antoine - Apr 18 '20 - - Dev Community

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!

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player