I had a null_resource that I deleted and now terraform plan is failing because of the provider doesn’t exist anymore. The provider is needed in the configuration to allow terraform to clean up the resource.
So in order to solve the issue I added the following to main.tf
terraform {
required_providers {
archive = "~> 1.3.0"
null = "~> 2.1.2"
}
}
However when I run terraform plan again it fails with
Error: Provider configuration not present
To work with null_resource.build_deps its original provider configuration at
provider["registry.terraform.io/-/null"] is required, but it has been removed.
This occurs when a provider configuration is removed while objects created by
that provider still exist in the state. Re-add the provider configuration to
destroy null_resource.build_deps, after which you can remove the provider
configuration again.
So I run terraform providers and I got the following
Providers required by configuration:
.
├── provider[registry.terraform.io/hashicorp/archive] ~> 1.3.0
├── provider[registry.terraform.io/hashicorp/null] ~> 2.1.2
└── provider[registry.terraform.io/hashicorp/aws] ~> 2.0
Providers required by state:
provider[registry.terraform.io/-/archive]
provider[registry.terraform.io/-/aws]
provider[registry.terraform.io/-/null]
Question
By looking at list of providers (required by configs vs required by state) you can see a slight difference in the source path. One is pulling the provider from HashiCorp in the path while the state providers has (-) in the path.
Any idea if this is what causing the problem? If so How can I fix it? Declaring providers differently maybe?