在VSCode中初始化Terraform AWS文件时遇区域限制类报错求助
Terraform初始化AWS Provider失败的解决方法
问题背景
执行terraform init时出现以下错误:
Initializing provider plugins...
- Finding latest version of hashicorp/aws...
╷
│ Error: Failed to install provider
│
│ Error while installing hashicorp/aws v5.44.0: could not query provider registry for registry.terraform.io/hashicorp/aws: failed to retrieve
│ authentication checksums for provider: 404 Not Found returned from releases.hashicorp.com
同时访问releases.hashicorp.com时提示地区不可用,当前使用Terraform版本为v1.8.0(windows_386)。
解决方案
1. 配置国内Provider镜像源
在Windows系统中,创建或编辑%APPDATA%\terraform.rc文件,添加以下配置:
provider_installation { network_mirror { url = "https://mirrors.tencent.com/terraform/" include = ["registry.terraform.io/hashicorp/*"] } }
保存文件后,重新执行terraform init。
2. 手动安装Provider插件
- 找到hashicorp/aws v5.44.0版本对应的windows_386架构安装包
- 解压安装包到本地插件目录:
%APPDATA%\terraform.d\plugins\registry.terraform.io\hashicorp\aws\5.44.0\windows_386,确保目录层级正确 - 执行
terraform init完成初始化
3. 通过代理访问
在PowerShell中设置代理环境变量后执行初始化:
$env:HTTP_PROXY="http://你的代理地址:端口" $env:HTTPS_PROXY="http://你的代理地址:端口" terraform init
内容的提问来源于stack exchange,提问作者Ghassan Abdullah
相关产品推荐
相关产品推荐

