github.com/kanishk98/terraform@v1.3.0-dev.0.20220917174235-661ca8088a6a/website/docs/cli/state/move.mdx (about) 1 --- 2 page_title: Moving Resources - Terraform CLI 3 description: >- 4 Commands that allow you to manage the way that resources are tracked in state. 5 They are helpful when you move or change resources. 6 --- 7 8 # Moving Resources 9 10 Terraform's state associates each real-world object with a configured resource 11 at a specific [resource address](/cli/state/resource-addressing). This 12 is seamless when changing a resource's attributes, but Terraform will lose track 13 of a resource if you change its name, move it to a different module, or change 14 its provider. 15 16 Usually that's fine: Terraform will destroy the old resource, replace it with a 17 new one (using the new resource address), and update any resources that rely on 18 its attributes. 19 20 In cases where it's important to preserve an existing infrastructure object, you 21 can explicitly tell Terraform to associate it with a different configured 22 resource. 23 24 For most cases we recommend using 25 [the Terraform language's refactoring features](/language/modules/develop/refactoring) 26 to document in your module exactly how the resource names have changed over 27 time. Terraform reacts to this information automatically during planning, so users of your module do not need to take any unusual extra steps. 28 29 > **Hands On:** Try the [Use Configuration to Move Resources](https://learn.hashicorp.com/tutorials/terraform/move-config) tutorial. 30 31 There are some other situations which require explicit state modifications, 32 though. For those, consider the following Terraform commands: 33 34 - [The `terraform state mv` command](/cli/commands/state/mv) changes 35 which resource address in your configuration is associated with a particular 36 real-world object. Use this to preserve an object when renaming a resource, or 37 when moving a resource into or out of a child module. 38 39 - [The `terraform state rm` command](/cli/commands/state/rm) tells 40 Terraform to stop managing a resource as part of the current working directory 41 and workspace, _without_ destroying the corresponding real-world object. (You 42 can later use `terraform import` to start managing that resource in a 43 different workspace or a different Terraform configuration.) 44 45 - [The `terraform state replace-provider` command](/cli/commands/state/replace-provider) 46 transfers existing resources to a new provider without requiring them to be 47 re-created.