TF complaints about deleted module's provider


I’ve deleted a 3rd party module from my TF code , but TF still complaints about missing external provider (used by that module).

The error that I get is:

Error: failed to read schema for in failed to instantiate provider "" to obtain schema: unavailable provider ""

I’ve run terraform init but the issue remains. My .terraform.lock.hcl file which is commited on my source control does not have the external provider setting.

provider "" {
  version     = "4.47.0"
  constraints = "~> 4.0"
  hashes = [


provider "" {
  version     = "3.4.3"
  constraints = "~> 3.0, ~> 3.1"
  hashes = [


If I get .terraform.lock.hcl from main, which has all the previous providers (including external), I can make it work locally but then my CI fails.

Do you guys have any suggestions, please?

Seems to be similar to AWS provider issue on MAC M1 · Issue #29993 · hashicorp/terraform · GitHub


Terraform remembers all of the resources that were present at the most recent terraform apply in the new state snapshot it creates.

After you remove a provider from your configuration you must run terraform apply once more to allow Terraform to remove any leftover objects that belonged to that provider. The terraform init command will install that provider so that Terraform is still able to interpret the previous state snapshot which still refers to that provider.

This means that you should also retain the entry in your .terraform.lock.hcl file until you’ve run terraform apply to remove the state file records of that provider.

Once you’ve run terraform apply at least once without the provider mentioned in your configuration there will no longer be any mention of the provider in your latest state snapshot and so terraform init (and other commands) will no longer need to install that provider.

1 Like