Terraform 0.13 Error: Provider configuration not present (module files not present anymore)


I am working on migrating a ton of modules from 0.11.4 to 0.13.6. I have deliberately not chosen directly to jump to 0.14 as there are some breaking changes, moving to 0.14 and then 0.15 are my next goals.

The problem is that a handful of modules have been deleted from terraform configuration files without using terraform destroy :frowning:

Now, the modules information is in terraform state but the actual files are lost. If I had those files, I would have used the provider specifically in the modules and fixed (like I have done with a lot of other modules).

# This is just an example, I have quite a few of these :(
To work with module.vault.data.aws_route53_zone.hosted_zone its original
provider configuration at
module.vault.provider["registry.terraform.io/hashicorp/aws"].R53 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
module.vault.data.aws_route53_zone.hosted_zone, after which you can remove the
provider configuration again.

Terraform Version

❯ terraform version                    
Terraform v0.13.6
+ provider registry.terraform.io/-/random v3.1.0
+ provider registry.terraform.io/hashicorp/aws v3.30.0
+ provider registry.terraform.io/hashicorp/external v2.1.0
+ provider registry.terraform.io/hashicorp/null v3.1.0
+ provider registry.terraform.io/hashicorp/random v3.1.0
+ provider registry.terraform.io/hashicorp/template v2.2.0


I know it is not recommended but can I just pull the state file and remove all JSON blocks of "module": "module.vault", or run terraform state rm on the modules.
I know it is not recommended way but I can’t think of anything else at the moment as I do not have the files anymore.


Hi @vikas027,

You can indeed use terraform state rm to ask Terraform to “forget” these objects that belong to a provider configuration that is no longer present.

The effect of that would be that Terraform would behave as if they had never existed, and so if those objects do still exist in the remote system then you’ll need to delete them manually.

However, in the example you showed here the mentioned resource is a data resource, and so having Terraform “forget” it should have no significant consequences: this configuration wasn’t actually managing that object anyway, so the state only contains a cached copy of the most recent data it read.

1 Like