terraform
refactoring
ai_generated
true
Error: Moved object still exists
ID: terraform/moved-block-error
92%Fix Rate
94%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 115 | active | — | — | — |
| 1 | active | — | — | — |
Root Cause
A moved block references a resource that still exists in the configuration.
genericWorkarounds
-
94% success Remove the old resource block after adding the moved block
moved { from = old_address; to = new_address } — then delete the old resource blockSources: https://developer.hashicorp.com/terraform/language/modules/develop/refactoring
-
90% success Run terraform plan to verify the move before applying
Plan should show 'moved' not 'destroy/create'
Dead Ends
Common approaches that don't work:
-
Removing the moved block and running apply
80% fail
Terraform will try to destroy the old resource and create a new one
-
Using terraform state rm to remove the old address
65% fail
May lose track of the resource; potential orphaned infrastructure
Error Chain
Frequently confused with: