OpenTofu Error: 'Provider configuration not present' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Provider configuration not present' when removing resources whose provider block is gone, using tofu state rm or restoring the provider.
- #opentofu
- #iac
- #troubleshooting
- #errors
Stuck on this OpenTofu error? Get the free incident triage checklist
A one-page PDF — the exact steps to isolate, fix, and verify a production error like this one. No spam, unsubscribe anytime.
What this error means
Every resource in state is tied to a provider configuration. If you delete a resource from config but its provider block (often an aliased one) is also gone, OpenTofu still needs that provider to destroy the leftover state object — and cannot find it:
Error: Provider configuration not present
To work with aws_instance.legacy (orphan) its original provider configuration
at provider["registry.opentofu.org/hashicorp/aws"].west 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 aws_instance.legacy (orphan), after which you can
remove the provider configuration again.
When it appears
tofu plan/applyfails withProvider configuration not present.- The message names an orphaned resource and the (aliased) provider it needs.
- Appears after deleting a
providerblock or removing a module that defined an aliased provider. - The resource still exists in state even though its config is gone.
Configuration causes
- Provider block removed while resources it created remain in state.
- Aliased provider deleted — the
.west/.replicaconfig was removed but its resources weren’t destroyed. - Module removed that supplied a
configuration_aliasesprovider. - Refactor order — config deleted before the resources were destroyed.
Validating the configuration
Read the orphaned resource address and provider alias from the error:
tofu plan 2>&1 | sed -n '1,15p'
Confirm the resource is still in state and which provider it references:
tofu state list | grep legacy
tofu state show 'aws_instance.legacy'
Check whether the provider/alias still exists in config:
grep -rn 'provider "aws"' *.tf
Resolution
Re-add the provider configuration, apply to destroy the orphan, then remove the provider block again:
provider "aws" {
alias = "west"
region = "us-west-2"
}
tofu apply # destroys aws_instance.legacy using the restored provider
Or remove the object from state if the real infrastructure is already gone (does not touch the cloud):
tofu state rm 'aws_instance.legacy'
Verify the plan is clean afterward:
tofu plan
Keeping definitions valid
- Destroy resources before deleting the provider that manages them; order matters in refactors.
tofu state rmonly forgets the object — use it only when the real resource is already deleted, or you will orphan live infrastructure.- Aliased providers defined in modules must outlive the resources they created.
- Prefer restoring the provider and running a real destroy over
state rmwhen the resource may still exist.
Related configuration errors
- OpenTofu Error: ‘Invalid provider configuration’ — Cause, Fix, and Troubleshooting Guide
- OpenTofu Error: ‘Invalid legacy provider address’ — Cause, Fix, and Troubleshooting Guide
- OpenTofu Error: ‘Provider does not support resource type’ — Cause, Fix, and Troubleshooting Guide
Fixed it? Get 500 OpenTofu & DevOps AI prompts — free
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.
Did this fix your issue?
Trending errors this week
The error guides other engineers are actually reading right now.
- 1mount: wrong fs type, bad option, bad superblock
- 2Docker 'failed to set up container networking': Fix the Bridge and IP Pool
- 3Docker 'failed to create shim task': How to Fix the containerd Runtime Error
- 4modprobe: FATAL: Module not found
- 5mount: wrong fs type, bad option, bad superblock
- 6Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
Get 500 Battle-Tested DevOps AI Prompts — Free
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.