Skip to content
DevOps AI ToolKit
Newsletter
All guides
AI for OpenTofu By James Joyner IV · · 8 min read

OpenTofu Error: 'Provider configuration not present' — Cause, Fix, and Troubleshooting Guide

Quick answer

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
Free toolkit

Fixing errors like this? Get 500 free DevOps AI prompts

500 copy-paste AI prompts for the stack you actually run — one PDF, free.

Overview

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.

Symptoms

  • tofu plan/apply fails with Provider configuration not present.
  • The message names an orphaned resource and the (aliased) provider it needs.
  • Appears after deleting a provider block or removing a module that defined an aliased provider.
  • The resource still exists in state even though its config is gone.

Common Root Causes

  • Provider block removed while resources it created remain in state.
  • Aliased provider deleted — the .west/.replica config was removed but its resources weren’t destroyed.
  • Module removed that supplied a configuration_aliases provider.
  • Refactor order — config deleted before the resources were destroyed.

How to diagnose

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

Fixes

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

What to watch out for

  • Destroy resources before deleting the provider that manages them; order matters in refactors.
  • tofu state rm only 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 rm when the resource may still exist.
Free download · 368-page PDF

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.