Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 460
allan.simon Avatar asked Jan 05 '21 17:01

allan.simon


People also ask

How do I upgrade my terraform provider?

Open your terraform.tf file and uncomment the cloud block. Replace the organization name with your own Terraform Cloud organization. Initialize your configuration. Terraform will automatically create the learn-terraform-provider-versioning workspace in your Terraform Cloud organization.

How do I find my terraform provider version?

Use the version subcommand to check your Terraform version and the version of any providers your configuration is using. Terraform will also let you know if there is a newer version of Terraform available. Attempt to initialize your project with terraform init .


1 Answers

I followed the steps 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

and it fixed my problem.

like image 59
allan.simon Avatar answered Oct 19 '22 08:10

allan.simon