【问题标题】:upgrade from 0.12 to 0.13: Failed to instantiate provider "registry.terraform.io/-/aws" to obtain从 0.12 升级到 0.13:无法实例化提供程序“registry.terraform.io/-/aws”以获取
【发布时间】:2021-04-11 11:33:13
【问题描述】:

我正在尝试从 terraform 0.12 升级到 0.13。

当我运行terraform 0.13upgrade 时,似乎没有具体的语法问题。

只添加了一个文件version.tf

+terraform {
+  required_providers {
+    aws = {
+      source = "hashicorp/aws"
+    }
+  }
+  required_version = ">= 0.13"
+}

当我运行 terraform plan 时,我得到了


Error: Could not load plugin


Plugin reinitialization required. Please run "terraform init".

Plugins are external binaries that Terraform uses to access and manipulate
resources. The configuration provided requires plugins which can't be located,
don't satisfy the version constraints, or are otherwise incompatible.

Terraform automatically discovers provider requirements from your
configuration, including providers used in child modules. To see the
requirements and constraints, run "terraform providers".

2 problems:

- Failed to instantiate provider "registry.terraform.io/-/aws" to obtain
schema: unknown provider "registry.terraform.io/-/aws"
- Failed to instantiate provider "registry.terraform.io/-/template" to obtain
schema: unknown provider "registry.terraform.io/-/template"

运行terraform providers 节目

Providers required by configuration:
.
├── provider[registry.terraform.io/hashicorp/aws]
├── module.bastion
│   ├── provider[registry.terraform.io/hashicorp/template]
│   └── provider[registry.terraform.io/hashicorp/aws]
└── module.vpc
    └── provider[registry.terraform.io/hashicorp/aws] >= 2.68.*

Providers required by state:

    provider[registry.terraform.io/-/aws]

    provider[registry.terraform.io/-/template]

所以我的猜测是出于某种原因,我的 tfstate 中有 -/aws 而不是 hashicorp/aws,但是我在 tfstate 中根本找不到这个特定的字符串。

我试过了:

  • 正在运行terraform init
  • terraform init -reconfigure
  • 删除.terraform 文件夹
  • 删除~/.terraform.d 文件夹

所以我没有办法解决这个问题

【问题讨论】:

  • 你试过terraform init -reconfigure吗?输出是什么?
  • 根据升级指南文档解释旧提供程序的 - 命名空间 (terraform.io/upgrade-guides/…),这不是问题的根本原因。
  • @MattSchuchard 实际上 replace provider 命令解决了我的问题,谢谢 :)
  • @allan.simon 您应该强烈考虑在问题跟踪器上提交错误报告,因为文档错误地声称该命令只会纠正外观问题,而不是功能问题。无论哪种方式,很高兴我的文档链接解决了您的问题。

标签: terraform terraform-provider-aws


【解决方案1】:

我按照步骤here

terraform state replace-provider   registry.terraform.io/-/template  registry.terraform.io/hashicorp/template
terraform state replace-provider   registry.terraform.io/-/aws  registry.terraform.io/hashicorp/aws

它解决了我的问题。

【讨论】:

  • 非常感谢!这让我很烦。
猜你喜欢
  • 2012-07-10
  • 1970-01-01
  • 2021-03-21
  • 2015-11-28
  • 2020-01-17
  • 2018-10-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多