Software Engineering

[Solved] Terraform Error accessing distant module registry in PowerShell

[Solved] Terraform Error accessing distant module registry in PowerShell
Written by admin


In case you are utilizing PowerShell and attempting to run a terraform init, it’s possible you’ll get an error as follows:

Error: error accessing distant module registry

Did not retrieve out there variations for module ... from registry.terraform.io: Did not request discovery doc: Get "https://registry.terraform.io/.well-known/terraform.json": learn tcp x.x.x.x:xxxx->x.x.x.x: wsarecv: An present connection was forcibly closed by the distant host..

Observe that you’ll nonetheless be capable to make a profitable curl request, however terraform will fail!

The issue

It’s essential to be sure you have a proxy set.

The Home windows Command Immediate helps you to set a proxy as follows:

SET HTTP_PROXY=http://<USER>:<PASSWORD>@proxy.host.com:8080
SET HTTPS_PROXY=http://<USER>:<PASSWORD>@proxy.host.com:8080
SET NO_PROXY=.yourcompany.com

The answer

PowerShell will nonetheless fail, because it required the proxy surroundings variables to even be set as follows:

[Environment]::SetEnvironmentVariable("HTTP_PROXY","http://<USER>:<PASSWORD>@proxy.host.com:8080/", [EnvironmentVariableTarget]::Course of)
[Environment]::SetEnvironmentVariable("HTTPS_PROXY","http://<USER>:<PASSWORD>@proxy.host.com:8080/", [EnvironmentVariableTarget]::Course of)
[Environment]::SetEnvironmentVariable("NO_PROXY",".yourcompany.com", [EnvironmentVariableTarget]::Course of)

About the author

admin

Leave a Comment