Terraform: unknown provider on apply 0.13.0-beta2

Created on 18 Jun 2020  ยท  14Comments  ยท  Source: hashicorp/terraform

Terraform Version

Terraform v0.13.0-beta2

Terraform Configuration Files

terraform {
  required_providers {
    local = {
      source  = "hashicorp/local"
      version = ">=1.4.0"
    }
    null = {
      source  = "hashicorp/null"
      version = ">=2.1.2"
    }
    random = {
      source  = "hashicorp/random"
      version = ">=2.2.1"
    }
    template = {
      source  = "hashicorp/template"
      version = ">=2.1.2"
    }
    aws = {
      source = "hashicorp/aws"
    }
    kubernetes = {
      source = "hashicorp/kubernetes"
    }
    tfe = {
      source = "hashicorp/tfe"
    }
  }

  backend "remote" {
    hostname     = "app.terraform.io"
    organization = "xxxx"

    # https://www.terraform.io/docs/backends/types/remote.html#configuration-variables
    workspaces {
      prefix = "global-"
    }
  }
}

Debug Output

Terraform v0.13.0-beta2
Initializing plugins and modules...

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".

4 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/-/local" to obtain
schema: unknown provider "registry.terraform.io/-/local"
- Failed to instantiate provider "registry.terraform.io/-/random" to obtain
schema: unknown provider "registry.terraform.io/-/random"
- Failed to instantiate provider "registry.terraform.io/-/template" to obtain
schema: unknown provider "registry.terraform.io/-/template"
Providers required by configuration:
.
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/template] >= 2.1.2
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/aws]
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/kubernetes]
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/tfe]
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/local] >= 1.4.0
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/null] >= 2.1.2
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/random] >= 2.2.1
โ”œโ”€โ”€ module.cluster
โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/aws]
โ”‚ย ย  โ”œโ”€โ”€ module.eks
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/template] >= 2.1.*
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/random] >= 2.1.*
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/kubernetes] >= 1.11.1
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/aws] >= 2.52.0
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/local] >= 1.4.*
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/null] >= 2.1.*
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ module.node_groups
โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/aws]
โ”‚ย ย  โ”‚ย ย      โ””โ”€โ”€ provider[registry.terraform.io/hashicorp/random]
โ”‚ย ย  โ””โ”€โ”€ module.vpc
โ”‚ย ย      โ””โ”€โ”€ provider[registry.terraform.io/hashicorp/aws] ~> 2.53
โ”œโ”€โ”€ module.dns
โ”‚ย ย  โ””โ”€โ”€ provider[registry.terraform.io/hashicorp/aws]
โ”œโ”€โ”€ module.secrets
โ”‚ย ย  โ””โ”€โ”€ provider[registry.terraform.io/hashicorp/aws]
โ””โ”€โ”€ module.workspaces
    โ””โ”€โ”€ provider[registry.terraform.io/hashicorp/tfe]

Providers required by state:

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

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

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

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

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

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

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



Crash Output

Expected Behavior

I expect the apply to occur.

Actual Behavior

Apply failed with error, even though the plan succeeds

Steps to Reproduce

Additional Context

Yes, I have completed many inits and I have deleted the '.terraform' directory.

I am using the following modules:
https://github.com/terraform-aws-modules/terraform-aws-vpc
https://github.com/terraform-aws-modules/terraform-aws-eks

I have tried forking the module repo's and adding required_providers stanza's there also, without success.

https://github.com/jurgenweber/terraform-aws-vpc/tree/0.13upgrade
https://github.com/jurgenweber/terraform-aws-eks/tree/0.13upgrade

'Providers required by state:' show this '-/' syntax, becuase the state was v0.12, do I need to update the state first or something?

References

v0.13

Most helpful comment

@jurgenweber Thanks for the update! I was able to reproduce the bug today. The tricky part was realizing that the use of nested modules was the cause, which as @bondsbw rightly points out (thanks!) has been reported elsewhere.

This bug has been fixed by #25334, which will be included in the next 0.13.0 prerelease, coming soon. Please reopen if you see the same issue with your configuration when trying with that release.

Thanks again for testing the 0.13 beta and for reporting this bug!

All 14 comments

Same issue for me with null provider.

Here is terraform validate

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".

Failed to instantiate provider "registry.terraform.io/hashicorp/null" to
obtain schema: unknown provider "registry.terraform.io/hashicorp/null"

And terraform providers

Providers required by configuration:
.
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/aws] ~> 2.54, ~> 2.*
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/tls] ~> 2.1
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/random]
โ”œโ”€โ”€ module.example
โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/aws] ~> 2.54
โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/template] ~> 2.1
โ”‚ย ย  โ”œโ”€โ”€ module.ssm_parameters
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ provider[registry.terraform.io/hashicorp/aws] ~> 2.47
โ”‚ย ย  โ”œโ”€โ”€ module.alb
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ provider[registry.terraform.io/hashicorp/aws] ~> 2.54
โ”‚ย ย  โ”œโ”€โ”€ module.asg
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/aws] ~> 2.54
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ provider[registry.terraform.io/hashicorp/null] ~> 2.1
โ”‚ย ย  โ””โ”€โ”€ module.common
โ”‚ย ย      โ””โ”€โ”€ provider[registry.terraform.io/hashicorp/aws] ~> 2.54
โ””โ”€โ”€ module.vpc
    โ””โ”€โ”€ provider[registry.terraform.io/hashicorp/aws] ~> 2.53

If I restart terraform init, I got a message that everything is ok.

Hi folks, thank you for reporting this issue!

EDIT: Terribly sorry, I did not read thoroughly! Y'all ran init! I will leave the rest of this comment as info for anyone _else_ running across this.
~Both of the messages shared included directions to run terraform init - have you done that already? If so, can you share the output? ~

There have been many changes to the provider installer between terraform v0.12 and v0.13, so you will need to run init again (and we highly recommend running terraform 0.13upgrade first).

Hi @mildwonkey

I delete my .terraform folder, and my .terraform.d folder.

I run again an init and a validate. It's still there.

here is my terrafaform version

Terraform v0.13.0-beta2
+ provider registry.terraform.io/hashicorp/aws v2.66.0
+ provider registry.terraform.io/hashicorp/random v2.2.1
+ provider registry.terraform.io/hashicorp/tls v2.0.1

This is my second terraform init

Initializing modules...

Initializing the backend...

Initializing provider plugins...
- Using previously-installed hashicorp/aws v2.66.0
- Using previously-installed hashicorp/random v2.2.1
- Using previously-installed hashicorp/tls v2.0.1

The following providers do not have any version constraints in configuration,
so the latest version was installed.

To prevent automatic upgrades to new major versions that may contain breaking
changes, we recommend adding version constraints in a required_providers block
in your configuration, with the constraint strings suggested below.

* hashicorp/random: version = "~> 2.2.1"

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

@quentin9696 This looks like it may be a separate issue from the original report. Would you mind opening a new issue? Please include your configuration, or if possible a reduced reproduction case.

@jurgenweber We've been trying to reproduce this issue today, without success. Can you describe in more detail the exact steps you're using to reproduce? Please include any details about your use of Terraform Cloud/Enterprise that may help us to figure this out.

If you can, a reduced reproduction case would be really helpful in tracking down what's going on here. Thanks in advance for your help!

just to clarify some of the comments above, I deleted the .terraform directories in both my tf code bases where I am seeing this. I completed the 0.13upgrade command on all directories and even forked community modules and ran 0.13 upgrade on them also (as linked in the original post) and sourced those locations (again, deleting .terraform directories and running init/validate/plan but on final apply in TFCloud it fails).

@alisdair I made a case with support yesterday also (just incase you are hashicorp staff), https://support.hashicorp.com/hc/requests/29660.. in the case I link the failing runs, etc that might help you debug. I"ll see if I can reproduce it today (I am in Australia, so TZ's, etc.).

I had a similar error, with data sources template_file and with external.

I replaced template_file with templatefile(). external continues to give the error, despite attempting terraform init, terraform init -reconfigure, terraform init -upgrade=true, and wiping .terraform.

More details: my state is in S3, upgraded from 0.12.26 to 0.13-beta2. I just deleted the only reference to external in the .tfstate file, wiped my local .terraform/ again, and I still get the same error on terraform plan.

Hi @bondsbw,

At this time we suspect that the problem described by this issue is specific the way that Terraform Cloud runs Terraform CLI as part of remote operations. Since you're using the S3 backend I assume you are not using Terraform Cloud remote runs (that would require the remote backend), so please open a new issue describing in more detail of the behavior you are seeing (using the bug report template) and we'll work on that separately. Thanks!

@alisdair I made a massively reduced code based and tried it and it worked but this is with a whole new workspace and a new state:

Providers required by configuration:
.
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/local]
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/null]
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/random]
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/template]
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/aws]
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/kubernetes]
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/tfe]
โ””โ”€โ”€ module.cluster
    โ”œโ”€โ”€ module.eks
    โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/template] >= 2.1.*
    โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/random] >= 2.1.*
    โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/kubernetes] >= 1.11.1
    โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/aws] >= 2.52.0
    โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/local] >= 1.4.*
    โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/null] >= 2.1.*
    โ”‚ย ย  โ””โ”€โ”€ module.node_groups
    โ”‚ย ย      โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/aws]
    โ”‚ย ย      โ””โ”€โ”€ provider[registry.terraform.io/hashicorp/random]
    โ””โ”€โ”€ module.vpc
        โ””โ”€โ”€ provider[registry.terraform.io/hashicorp/aws] ~> 2.53

note it doesn't have the 'Providers required by state:' section.

I will do another test with this code base and start with v0.12 and then try to convert.... I will then report back.

ok, that is it... The same code base but I started on 0.12.

$ tf version
  1 terraform {
Terraform v0.12.26
+ provider.aws v2.66.0
+ provider.kubernetes v1.11.3
+ provider.local v1.4.0
  1 module "vpc" {
+ provider.null v2.1.2
+ provider.random v2.2.1
+ provider.template v2.1.2
 $ tf providers
.
โ”œโ”€โ”€ provider.aws
โ”œโ”€โ”€ provider.kubernetes
โ””โ”€โ”€ module.cluster
    โ”œโ”€โ”€ module.eks
    โ”‚ย ย  โ”œโ”€โ”€ provider.aws >= 2.52.0
    โ”‚ย ย  โ”œโ”€โ”€ provider.kubernetes >= 1.11.1
    โ”‚ย ย  โ”œโ”€โ”€ provider.local >= 1.4
    โ”‚ย ย  โ”œโ”€โ”€ provider.null >= 2.1
    โ”‚ย ย  โ”œโ”€โ”€ provider.random >= 2.1
    โ”‚ย ย  โ”œโ”€โ”€ provider.template >= 2.1
    โ”‚ย ย  โ””โ”€โ”€ module.node_groups
    โ”‚ย ย      โ”œโ”€โ”€ provider.aws (inherited)
    โ”‚ย ย      โ””โ”€โ”€ provider.random
    โ””โ”€โ”€ module.vpc
        โ””โ”€โ”€ provider.aws ~> 2.53

I then updated the binary to 0.13
I updated the module sources to my repo's that have had 0.13upgrade run on them.
I update the main code base to be 0.13 compatible with a versions.tf.
I update the TFCloud workspace to be 0.13beta2
I rm -rf .terraform

 $ tf init
Initializing modules...

Initializing the backend...

The currently selected workspace (default) does not exist.
  This is expected behavior when the selected workspace did not have an
  existing non-empty state. Please enter a number to select a workspace:

  1. 013

  Enter a value: 1


Initializing provider plugins...
- Finding latest version of hashicorp/local...
- Finding latest version of -/null...
- Finding latest version of hashicorp/template...
- Finding latest version of hashicorp/kubernetes...
- Finding latest version of hashicorp/tfe...
- Finding latest version of -/random...
- Finding latest version of -/aws...
- Finding latest version of -/kubernetes...
- Finding latest version of -/local...
- Finding latest version of hashicorp/random...
- Finding latest version of hashicorp/aws...
- Finding latest version of -/template...
- Finding latest version of hashicorp/null...
- Installing hashicorp/kubernetes v1.11.3...
- Installed hashicorp/kubernetes v1.11.3 (signed by HashiCorp)
- Installing hashicorp/tfe v0.19.0...
- Installed hashicorp/tfe v0.19.0 (signed by HashiCorp)
- Installing -/random v2.2.1...
- Installed -/random v2.2.1 (signed by HashiCorp)
- Installing -/aws v2.67.0...
- Installed -/aws v2.67.0 (signed by HashiCorp)
- Installing hashicorp/aws v2.67.0...
- Installed hashicorp/aws v2.67.0 (signed by HashiCorp)
- Installing hashicorp/random v2.2.1...
- Installed hashicorp/random v2.2.1 (signed by HashiCorp)
- Installing -/template v2.1.2...
- Installed -/template v2.1.2 (signed by HashiCorp)
- Installing hashicorp/null v2.1.2...
- Installed hashicorp/null v2.1.2 (signed by HashiCorp)
- Installing hashicorp/local v1.4.0...
- Installed hashicorp/local v1.4.0 (signed by HashiCorp)
- Installing -/null v2.1.2...
- Installed -/null v2.1.2 (signed by HashiCorp)
- Installing hashicorp/template v2.1.2...
- Installed hashicorp/template v2.1.2 (signed by HashiCorp)
- Installing -/kubernetes v1.11.3...
- Installed -/kubernetes v1.11.3 (signed by HashiCorp)
- Installing -/local v1.4.0...
- Installed -/local v1.4.0 (signed by HashiCorp)

The following providers do not have any version constraints in configuration,
so the latest version was installed.

To prevent automatic upgrades to new major versions that may contain breaking
changes, we recommend adding version constraints in a required_providers block
in your configuration, with the constraint strings suggested below.

* -/aws: version = "~> 2.67.0"
* -/kubernetes: version = "~> 1.11.3"
* -/local: version = "~> 1.4.0"
* -/null: version = "~> 2.1.2"
* -/random: version = "~> 2.2.1"
* -/template: version = "~> 2.1.2"
* hashicorp/aws: version = "~> 2.67.0"
* hashicorp/kubernetes: version = "~> 1.11.3"
* hashicorp/local: version = "~> 1.4.0"
* hashicorp/null: version = "~> 2.1.2"
* hashicorp/random: version = "~> 2.2.1"
* hashicorp/template: version = "~> 2.1.2"
* hashicorp/tfe: version = "~> 0.19.0"

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

 $ tf providers

Providers required by configuration:
.
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/null]
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/random]
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/template]
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/aws]
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/kubernetes]
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/tfe]
โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/local]
โ””โ”€โ”€ module.cluster
    โ”œโ”€โ”€ module.eks
    โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/aws] >= 2.52.0
    โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/local] >= 1.4.*
    โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/null] >= 2.1.*
    โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/template] >= 2.1.*
    โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/random] >= 2.1.*
    โ”‚ย ย  โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/kubernetes] >= 1.11.1
    โ”‚ย ย  โ””โ”€โ”€ module.node_groups
    โ”‚ย ย      โ”œโ”€โ”€ provider[registry.terraform.io/hashicorp/aws]
    โ”‚ย ย      โ””โ”€โ”€ provider[registry.terraform.io/hashicorp/random]
    โ””โ”€โ”€ module.vpc
        โ””โ”€โ”€ provider[registry.terraform.io/hashicorp/aws] ~> 2.53

Providers required by state:

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

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

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

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

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

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

as you can see, these odd providers are back. I then commited the 0.13 compatibility changes to my repo and TFCloud plan runs and completes but the apply fails:

Terraform v0.13.0-beta2
Initializing plugins and modules...

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".

4 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/-/local" to obtain
schema: unknown provider "registry.terraform.io/-/local"
- Failed to instantiate provider "registry.terraform.io/-/random" to obtain
schema: unknown provider "registry.terraform.io/-/random"
- Failed to instantiate provider "registry.terraform.io/-/template" to obtain
schema: unknown provider "registry.terraform.io/-/template"

I can not do anytihng with the workspace, not even destroy it.. so I have to revert back to 0.12 to kill it. :)

This appears to be related to multiple levels of module nesting. See #25312 for a simple repro with local state. No conversion from 0.12 was made.

@jurgenweber Thanks for the update! I was able to reproduce the bug today. The tricky part was realizing that the use of nested modules was the cause, which as @bondsbw rightly points out (thanks!) has been reported elsewhere.

This bug has been fixed by #25334, which will be included in the next 0.13.0 prerelease, coming soon. Please reopen if you see the same issue with your configuration when trying with that release.

Thanks again for testing the 0.13 beta and for reporting this bug!

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings