Skip to content

Error when using terraform inside WSL2 #8022

@b1ackhawk-uh60

Description

@b1ackhawk-uh60

Version

Microsoft Windows [Version 10.0.19044.1503]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

Kernel version: 5.10.60.1

Distro Version

Ubuntu 20.04

Other Software

Terraform v1.1.5

Repro Steps

Run terraform refresh or any command that is doing a refresh (like plan/apply) in WSL2.

Expected Behavior

for terraform refresh to complete as usual.
This was working as of 3 days ago.

Actual Behavior

Refresh does not complete and and error message is presented:
│ Error: Unable to list provider registration status, it is possible that this is due to invalid credentials or the service principal does not have permission to use the Resource Manager API, Azure error: resources.ProvidersClient#List: Failure sending request: StatusCode=0 -- Original Error: Get "https://management.azure.com/subscriptions/{my-subscription-id}/providers?api-version=2016-02-01": dial tcp: lookup management.azure.com on 172.30.96.1:53: cannot unmarshal DNS message

│ with provider["registry.terraform.io/hashicorp/azurerm"],
│ on main.tf line 10, in provider "azurerm":
│ 10: provider "azurerm" {

This consistently happens but only with the following conditions:
Running in WSL2 with my primary ISP (Xfinity) and connected to either WiFi or Ethernet

I've tried swapping out my router for a different make/model - Issue still persists
I've test on another computer, also outfitted with WSL2 (however running Ubuntu 18.04) - the issue persists
I've tested using different DNS providers - the issue persists
Also note that other tools seem to work fine (like azure cli) from WSL2, dns for managment.azure.com resolves fine (nslookup provides expected results)

Conditions where the issue does not persist and terraform operates normally:
If I simply convert WSL2 to WSL1 - no issue, terraform operates normally
If I run terraform from Windows (on the same machine) instead of WSL2 - no issue, terraform operates normally
If I connect my computer via WiFi to my phones wireless hotspot - no issue, terraform operates normally
If I connect to VPN in Windows - no issue, terraform operates normally

So it seems to be some combination of WSL2 and my ISP.

Diagnostic Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions