Introduction
Terraform raises Error: Provider configuration not present when state still points to a provider alias that no longer exists in code. This usually happens after renaming an alias, deleting a child module, or moving resources into a new module without migrating state first.
Symptoms
terraform planfails before showing any resource diff- The error references an alias such as
aws.sharedor a child module provider mapping - Older resources fail while new resources in the same config work normally
- The issue starts right after a module refactor or alias cleanup
Common Causes
- A provider alias was deleted while resources using it still exist in state
- A child module no longer receives the expected
providersmapping - Resources moved to a new address without a state migration
- The team removed configuration before destroying or reattaching legacy resources
Step-by-Step Fix
- 1.Inspect the provider addresses Terraform still sees
- 2.Find the exact alias and state addresses that still depend on the missing provider configuration.
terraform providers
terraform state list
terraform state show module.network.aws_vpc.main- 1.Temporarily restore the missing alias
- 2.Re-add the old provider alias or module mapping so Terraform can read and update the existing state safely.
```hcl provider "aws" { alias = "shared" region = var.region }
module "network" { source = "./modules/network" providers = { aws = aws.shared } } ```
- 1.Migrate state to the new provider address if the alias really changed
- 2.Once the old alias is back, replace the provider reference deliberately instead of hoping init will fix it.
terraform state replace-provider \
'registry.terraform.io/hashicorp/aws.shared' \
'registry.terraform.io/hashicorp/aws'- 1.Run a clean plan before removing the temporary alias
- 2.Do not delete the restored alias until
terraform providersno longer shows resources pinned to it.
terraform plan
terraform providersPrevention
- Treat provider alias renames as state migrations, not as routine cleanup
- Run
terraform providersbefore and after module refactors - Use
movedblocks or documented state commands for address changes - Review child module provider mappings during code review