How to set up terraform behind proxy?

Hello everybody,

Does anyone know the answer to this question? I will be very grateful if you can help How to set up terraform behind proxy? - Stack Overflow

Regards,

Antoine.

Hi @nobac3,

I’m just going to copy the error message over here so that folks who find this topic rather than the Stack Overflow question can easily see what we’re talking about:

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 

This error suggests to me that Terraform did attempt to make use of the proxies you configured, but that the proxy you chose isn’t a TLS (HTTPS) proxy, and so the connection failed.

If your proxy has both a cleartext HTTP and an HTTPS interface then I think you’d need to set HTTPS_PROXY to the HTTPS interface, which will then allow Terraform to make a secure connection to the proxy before using the proxy to make a connection to the registry.

1 Like