--- description: >- Commands that allow you to manage the way that resources are tracked in state. They are helpful when you move or change resources. --- # Moving Resources OpenTofu's state associates each real-world object with a configured resource at a specific [resource address](resource-addressing.mdx). This is seamless when changing a resource's attributes, but OpenTofu will lose track of a resource if you change its name, move it to a different module, or change its provider. Usually that's fine: OpenTofu will destroy the old resource, replace it with a new one (using the new resource address), and update any resources that rely on its attributes. In cases where it's important to preserve an existing infrastructure object, you can explicitly tell OpenTofu to associate it with a different configured resource. For most cases we recommend using [the OpenTofu language's refactoring features](../../language/modules/develop/refactoring.mdx) to document in your module exactly how the resource names have changed over time. OpenTofu reacts to this information automatically during planning, so users of your module do not need to take any unusual extra steps. There are some other situations which require explicit state modifications, though. For those, consider the following OpenTofu commands: - [The `tofu state mv` command](../commands/state/mv.mdx) changes which resource address in your configuration is associated with a particular real-world object. Use this to preserve an object when renaming a resource, or when moving a resource into or out of a child module. - [The `tofu state rm` command](../commands/state/rm.mdx) tells OpenTofu to stop managing a resource as part of the current working directory and workspace, _without_ destroying the corresponding real-world object. (You can later use `tofu import` to start managing that resource in a different workspace or a different OpenTofu configuration.) - [The `tofu state replace-provider` command](../commands/state/replace-provider.mdx) transfers existing resources to a new provider without requiring them to be re-created.