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 plan fails before showing any resource diff
  • The error references an alias such as aws.shared or 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 providers mapping
  • 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. 1.Inspect the provider addresses Terraform still sees
  2. 2.Find the exact alias and state addresses that still depend on the missing provider configuration.
bash
terraform providers
terraform state list
terraform state show module.network.aws_vpc.main
  1. 1.Temporarily restore the missing alias
  2. 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. 1.Migrate state to the new provider address if the alias really changed
  2. 2.Once the old alias is back, replace the provider reference deliberately instead of hoping init will fix it.
bash
terraform state replace-provider \
  'registry.terraform.io/hashicorp/aws.shared' \
  'registry.terraform.io/hashicorp/aws'
  1. 1.Run a clean plan before removing the temporary alias
  2. 2.Do not delete the restored alias until terraform providers no longer shows resources pinned to it.
bash
terraform plan
terraform providers

Prevention

  • Treat provider alias renames as state migrations, not as routine cleanup
  • Run terraform providers before and after module refactors
  • Use moved blocks or documented state commands for address changes
  • Review child module provider mappings during code review