How to set up terraform behind proxy?

abc*_*est 6 proxy terraform

I am trying to run terraform behind a proxy on Windows. I have already set my proxy on CMD by doing: set HTTP_PROXY and set HTTPS_PROXY.

Here is the error I am getting:

Initializing provider plugins...
- Finding latest version of hashicorp/aws...

Error: Failed to query available provider packages

Could not retrieve the list of available versions for provider hashicorp/aws:
could not connect to registry.terraform.io: Failed to request discovery
document: Get "https://registry.terraform.io/.well-known/terraform.json":
proxyconnect tcp: tls: first record does not look like a TLS handshake 
Run Code Online (Sandbox Code Playgroud)

There are no problem in my infrastructure as I have already tried it on another computer with no proxy and it works.

Thank you in advance.

Asr*_*lah 4

我通过设置环境变量来使用带密码的 terraform 代理,如下所示:

HTTP_PROXY=http://<username>:<password>@<proxy>:<port>
HTTPS_PROXY=http://<username>:<password>@<proxy>:<port>
Run Code Online (Sandbox Code Playgroud)

HTTPS_PROXY设置为 http url而不是https