terraform
state_error
ai_generated
partial
Error: Module output depends on resource that no longer exists
ID: terraform/depends-on-module
80%Fix Rate
85%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1 | active | — | — | — |
Root Cause
Module references a resource that was removed from config but exists in state.
genericWorkarounds
-
92% success Use terraform state rm to remove the orphaned resource from state
terraform state rm module.name.resource_type.name
Sources: https://developer.hashicorp.com/terraform/cli/commands/state/rm
-
85% success Run terraform plan to see what will change, then targeted apply if needed
terraform plan -target=module.name
Sources: https://developer.hashicorp.com/terraform/cli/commands/plan
-
82% success Use terraform state list to inventory what's tracked vs what's in config
Use terraform state list to inventory what's tracked vs what's in config
Sources: https://developer.hashicorp.com/terraform/cli/commands/state/list
Dead Ends
Common approaches that don't work:
-
Delete the entire module and recreate
75% fail
Destroys all resources in the module — may cause outage
-
Manually edit the state JSON
80% fail
Error-prone — one mistake can corrupt the entire state
Error Chain
Frequently confused with: