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/aws" to obtain
schema: unknown provider "registry.terraform.io/hashicorp/aws"
Authenticating with credentials from /root/.docker/config.json
although we have also replaced the provider
terraform state replace-provider -auto-approve registry.terraform.io/-/aws registry.terraform.io/hashicorp/aws
terraform state replace-provider -auto-approve registry.terraform.io/-/external registry.terraform.io/hashicorp/external
terraform state replace-provider -auto-approve registry.terraform.io/-/null registry.terraform.io/hashicorp/null
terraform state replace-provider -auto-approve registry.terraform.io/-/random registry.terraform.io/hashicorp/random
terraform state replace-provider -auto-approve registry.terraform.io/-/template registry.terraform.io/hashicorp/template
apart from this we had also used required_providers but no luck please suggest
Can you also include the result of running terraform init? I think that’ll be the more interesting command to see here, because it’s the one responsible for installing the hashicorp/aws provider for the other commands to find.
Even we are receiving the same error after upgrading the scripts from 0.14.7 to the latest 1.0.2.
terraform apply show below error
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”.
│
│ 3 problems:
│
│ - failed to instantiate provider “registry.terraform.io/hashicorp/aws” to obtain schema: unknown provider “registry.terraform.io/hashicorp/aws”
│ - failed to instantiate provider “registry.terraform.io/hashicorp/local” to obtain schema: unknown provider “registry.terraform.io/hashicorp/local”
│ - failed to instantiate provider “registry.terraform.io/hashicorp/template” to obtain schema: unknown provider “registry.terraform.io/hashicorp/template”
│
We tried remove the terraform provider folder and recreate using terraform init command, but the issue is same.
Below is the output of terraform init -upgrade command after we removed terraform folder.
Initializing the backend…
Successfully configured the backend “s3”! Terraform will automatically
use this backend unless the backend configuration changes.
Installed hashicorp/aws v3.49.0 (signed by HashiCorp)
Installing hashicorp/local v2.1.0…
Installed hashicorp/local v2.1.0 (signed by HashiCorp)
Installing hashicorp/template v2.2.0…
Installed hashicorp/template v2.2.0 (signed by HashiCorp)
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.
In my case, I was running terraform init consecutively to run terraform plan against multiple tfstates in a single job, and I had to install the plugin each time.
I reduced the number of installs by using TF_PLUGIN_CACHE_DIR to share the cache, and the error is no longer reproduced.