Refactoring State with moved and removed
Safely rename and restructure resources without destroying infrastructure by using state manipulation commands and the declarative moved and removed blocks.
The Renaming Problem
When you rename a resource in your config, Terraform sees the old address gone and a new one appearing. By default it will destroy and recreate the resource, which can mean downtime or data loss.
State refactoring tools let you tell Terraform that a resource simply moved.
Inspecting State
Start by listing what is tracked in state. The terraform state list command shows every managed resource address.
terraform state listAll lessons in this course
- Remote State Backends
- State Locking and Consistency
- Importing Existing Resources
- Refactoring State with moved and removed