#-------------------------------------------------------------------------------------------------------
# Set terraform version and providers
#-------------------------------------------------------------------------------------------------------
terraform {
required_version = ">= 1.3.0"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">=3.0.0"
}
}
}
provider "azurerm" {
features {
resource_group {
prevent_deletion_if_contains_resources = false
}
}
}
Install Terraform on wsl
Open Ubuntu application (or your installed distro)
Run the following command which will install unzip (its my preference to extract files)
sudo apt-get install unzip
Navigate to the Terraform download page and grab the most recent download URL.
Using the above URL, run the following commands which will download, unzip, move the binary to users bin.
wget <terraform_url> -O terraform.zip;
unzip terraform.zip;
sudo mv terraform /usr/local/bin;
rm terraform.zip;
The recommend using the following commands to install Terraform. It skip validating certificate, so we are able to install Terraform without any unexpected error:
TER_VER=`curl -s https://api.github.com/repos/hashicorp/terraform/releases/latest | grep tag_name | cut -d: -f2 | tr -d \"\,\v | awk '{$1=$1};1'`
wget --no-check-certificate https://releases.hashicorp.com/terraform/${TER_VER}/terraform_${TER_VER}_linux_amd64.zip
unzip terraform.zip;
unzip terraform_${TER_VER}_linux_amd64.zip
sudo mv terraform /usr/local/bin/
rm terraform_${TER_VER}_linux_amd64.zip
Run the following command to verify terraform is installed.
reference: Configuring Terraform on Windows 10 Linux Sub-System