terraform
refactor_error
ai_generated
true
Error: Moved object no longer exists or moved block is invalid
ID: terraform/tf-moved-block-error
85%Fix Rate
87%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1 | active | — | — | — |
Root Cause
A moved block references a source or destination that does not exist or is invalid.
genericWorkarounds
-
88% success Verify both the from and to addresses are valid resource addresses in the current configuration
moved { from = OLD_ADDRESS; to = NEW_ADDRESS } - OLD_ADDRESS must exist in state, NEW_ADDRESS must exist in configSources: https://developer.hashicorp.com/terraform/language/modules/develop/refactoring
-
85% success Use terraform state mv as an alternative for one-time moves
terraform state mv OLD_ADDRESS NEW_ADDRESS for immediate state change without a moved block
Sources: https://developer.hashicorp.com/terraform/cli/commands/state/mv
Dead Ends
Common approaches that don't work:
-
Chain multiple moved blocks to create a move history
80% fail
Terraform does not support transitive moves; each moved block must reference the current state address directly
-
Use moved blocks to move resources between different state files
90% fail
Moved blocks only work within a single state file; cross-state moves require state mv or import
Error Chain
Preceded by: