Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.9k views
in Technique[技术] by (71.8m points)

upgrade from 0.12 to 0.13: Failed to instantiate provider "registry.terraform.io/-/aws" to obtain

I'm trying to upgrade from terraform 0.12 to 0.13.

it seems to have no specific problem of syntax when I run terraform 0.13upgrade nothing is changed.

only a file version.tf is added

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

and when I run terraform plan I got


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"

running terraform providers shows

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]

So my guess is form some reason I have -/aws instead of hashicorp/aws in my tfstate, however I can't find this specific string at all in the tfstate.

I tried:

  • running terraform init
  • terraform init -reconfigure
  • deleting the .terraform folder
  • deleting the ~/.terraform.d folder

So I'm running out of ideas on how to solve this problem


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I followed the steps here https://www.terraform.io/upgrade-guides/0-13.html#why-do-i-see-provider-during-init-

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

and it fixed my problem


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...