Terraform moved block: address changes and identity
Renaming a resource label changes its Terraform address. Without a mapping, Terraform can interpret that edit as an old resource removed and a new resource added.
moved {
from = lab_server.api
to = lab_server.dispatch
}
This original example tells the course model how the previous address relates to the new one. Keep the resource’s provider identity and review the plan. A state move does not rename the physical provider object. Changing an immutable provider argument at the same time can still require replacement.
A declarative moved block records the mapping for collaborators who apply the configuration later. An imperative terraform state mv changes a particular state immediately. Their operational timing differs, so coordinate state writers and retain a recovery record before manual state work.
The official refactoring guide explains address moves. Practice state inspection and import to distinguish an existing binding from adoption of an unmanaged object.