Terraform "Provider configuration not present" in CI
A resource that still exists in state references a provider that is no longer declared in the configuration, so Terraform cannot find a provider to plan or destroy it.
What this error means
plan/apply fails with "Provider configuration not present", naming a resource whose provider block was deleted or renamed. It surfaces after removing a provider, splitting modules, or dropping an aliased provider while resources remain in state.
Error: Provider configuration not present
To work with aws_s3_bucket.legacy its original provider configuration at
provider["registry.terraform.io/hashicorp/aws"].old is required, but it has been
removed. This occurs when a provider configuration is removed while objects
created by that provider still exist in state.Common causes
Provider block deleted while resources remain
The provider (or its alias) was removed from config, but objects it created are still tracked in state, leaving them with no provider to manage them.
Provider renamed or alias dropped
Renaming a provider or removing an alias the resources used breaks the mapping between state objects and a live provider configuration.
How to fix it
Re-declare the provider, then migrate or destroy cleanly
- Temporarily restore the provider block (or alias) that the state objects reference.
- Either destroy the orphaned resources, or use a moved/state mv to re-home them under the new provider.
- Once state no longer references the old provider, remove the block again.
provider "aws" {
alias = "old"
region = "us-east-1"
}
# then: terraform state list | grep legacy
# and either destroy or move the resource under the new providerHow to prevent it
- Destroy or migrate resources before deleting their provider block.
- Use a moved block or state mv when re-homing resources across providers.
- Run plan after any provider/alias removal to catch orphaned objects.