OpenTofu Error: 'Invalid legacy provider address' — Cause, Fix, and Troubleshooting Guide
Fix OpenTofu 'Error: Invalid legacy provider address' after migrating state from Terraform by running tofu state replace-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
Older state written by early Terraform recorded providers with an unqualified “legacy” address like aws instead of the fully qualified registry.opentofu.org/hashicorp/aws. When OpenTofu reads such state it needs a proper source address and cannot resolve the legacy form:
Error: Invalid legacy provider address
This configuration or its associated state refers to the unqualified provider
"aws".
You must complete the Terraform 0.13 upgrade process before upgrading to later
versions, or migrate the provider address with:
tofu state replace-provider registry.opentofu.org/-/aws registry.opentofu.org/hashicorp/aws
How it presents
tofu plan/initfails withInvalid legacy provider addressnaming an unqualified provider.- The state references a provider as a bare name (
aws,google) with a-/namespace. - Appears when adopting OpenTofu (or upgrading) with very old state.
- Blocks operations until the provider address in state is rewritten.
Tracing the connection
Read which unqualified provider the error names, then inspect the state:
tofu plan 2>&1 | sed -n '1,15p'
tofu state pull | jq '.resources[].provider' | sort -u
List the legacy addresses that need rewriting:
tofu state pull | jq -r '.resources[].provider' | grep -- '/-/'
Network path causes
- Very old state created before Terraform 0.13’s qualified provider addresses.
- Skipped 0.13 upgrade — the legacy address was never migrated.
- Imported/merged legacy state into a modern configuration.
- State hand-edited to a bare provider name.
Remediation steps
Rewrite the provider address in state with state replace-provider, mapping the legacy form to the qualified one:
tofu state replace-provider \
registry.opentofu.org/-/aws \
registry.opentofu.org/hashicorp/aws
Repeat for each legacy provider the error lists (google, azurerm, etc.):
tofu state replace-provider registry.opentofu.org/-/google registry.opentofu.org/hashicorp/google
Confirm the state is clean afterward:
tofu state pull | jq -r '.resources[].provider' | sort -u
tofu plan
Back up first — pull a copy of state before rewriting:
tofu state pull > state-backup-$(date +%s).json
Keeping the path healthy
- Always back up state before
replace-provider; it rewrites every matching resource. - Run one
replace-providerper legacy provider — the error lists them one at a time. - After migrating, re-run
tofu initso the qualified provider is installed and locked. - This is a one-time migration; once state is rewritten and committed, it will not recur.
Related connectivity errors
- OpenTofu Error: ‘Provider configuration not present’ — Cause, Fix, and Troubleshooting Guide
- OpenTofu Error: ‘Invalid provider configuration’ — Cause, Fix, and Troubleshooting Guide
- Migrating from Terraform to OpenTofu: A Practical 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.