[terraform]错误:解决“无法查询可用的提供程序软件包”的方法[terraform]错误:解决“无法查询可用的提供程序软件包”的方案[terraform]错误:如何解决“无法查询可用的提供程序软件包”

出现错误信息

% terraform init                  

Initializing the backend...

Successfully configured the backend "s3"! Terraform will automatically
use this backend unless the backend configuration changes.

Initializing provider plugins...
- terraform.io/builtin/terraform is built in to Terraform
- Finding latest version of hashicorp/teraform...
- Finding hashicorp/aws versions matching "3.42.0"...
- Installing hashicorp/aws v3.42.0...
- Installed hashicorp/aws v3.42.0 (signed by HashiCorp)
╷
│ Error: Failed to query available provider packages
│ 
│ Could not retrieve the list of available versions for provider hashicorp/teraform: provider registry registry.terraform.io does not have a provider named registry.terraform.io/hashicorp/teraform
│ 
│ All modules should specify their required_providers so that external consumers will get the correct providers when using a module. To see which modules are currently depending on hashicorp/teraform, run the following command:
│     terraform providers
╵

造成这种情况的原因是什么?

查看错误消息,似乎提供者的设置有误,但实际上是由于data.tf中内容的类型错误引起的错误。

# ↓この行をミスしていた。正しくは"terraform_remote_state"だった。
data "teraform_remote_state" "network_main" { 
  backend = "s3"

  config = {
    buket  = "social-game-tfstate"
    key    = "${local.system_name}/${local.env_name}/network/main=v1.0.0.tfstate"
    region = "ap-northeast-1"
  }
}

解决方案 ‘àn)

修改terraform的配置文件(.tf文件),然后重新运行terraform init命令。

除了本次調查找到的例子外,还有其他的案例。

有时,当升级版本导致标题错误时,可以尝试以下方法进行修复:
https://discuss.hashicorp.com/t/terraform-0-13-terraform-init-fails-because-of-provider-required-by-state/13132

广告
将在 10 秒后关闭
bannerAds