首页 > 解决方案 > 我正在尝试运行 terraform init 但收到此错误:无法查询可用的提供程序包

问题描述

Terraform init 给出以下错误。没有版本升级,几天前它还在工作,但突然它失败了。

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": read: connection reset by peer


when I run curl from the server, it is not able to connect as well. 
 curl https://registry.terraform.io/
 curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to registry.terraform.io:443

标签: terraformterraform-provider-awshashicorp

解决方案


您是否在管理员可能在您和 Internet 之间安装了代理的网络上?如果是这样,您需要获取签名证书并在您的提供程序中配置它们。

如果您在家庭网络或公共网络上,这是中间人攻击。请勿使用此网络。

如果您有证书,则可以通过在您的 aws 提供程序中配置它们,方法是指向cacert_path,cert_path并指向key_path相应的.pem文件。

如果您已经验证有正当理由在您和互联网之间建立代理,您没有接触生产,并且证书很难获得,您可以通过insecure = true在您的提供商上设置来测试您的代码。显然,不要检查。


推荐阅读