I am not a developer and have been looking for a reason to use WSL for a while and found a good use case to Terraform using VS Code on Linux.
In my opinion Hashicorp’s Terraform is the de facto choice in the infrastructure as code space just like Kubernetes is for container orchestration. It provides the ability to version your infrastructure and automate the provisioning of your resources across different cloud vendors as well as on-premise.
To get this working requires a couple of steps which I will provide here. Also at the time of writing this I am running Windows 10 Pro, with Version 10.0.18362 Build 18362.
Install WSL:
- Open Powershell as Administrator and run the following command to enable this feature
- “Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux”
- Open MS store and download your favorite distribution, I selected Ubuntu.
- Don’t close the store just yet and wait for the installation to complete.
- You can also open from command prompt by typing “Ubuntu.exe” from the distro installation folder, or selecting ubuntu from app menu.
- Don’t close the store just yet and wait for the installation to complete.
- Create a UNIX username
- Create a UNIX password
- Now lets update our distro to latest
- Run “sudo apt-get update”
- Run “sudo apt-get upgrade”
- Done
Install Terraform on linux distro:
- Run the following commands to install unzip
- “sudo apt-get install unzip”
- Copy the link address to latest Linux 64-bit download from this page here
- Run the following command to install Terraform
- “wget https://releases.hashicorp.com/terraform/0.12.7/terraform_0.12.7_linux_amd64.zip”
- “unzip terraform_0.12.7_linux_amd64.zip”
- “sudo mv terraform /usr/local/bin”
- Run the following command to verify its has been implemented successfully
- “terraform version”
- Should show “Terraform v0.12.7” (based on the version I downloaded)
Install the Azure and AWS CLI on the linux distro
This is not necessary but super useful if you have deploying to these cloud vendors.
- Azure CLI installation steps
- Run the following command to verify its working
- “az -v”
- Run the following command to verify its working
- AWS CLI installation steps
- Run the following command to install
- “sudo apt-get install awscli”
- Run the following command to verify its working
- “aws version”
- Run the following command to install