github.com/hugorut/terraform@v1.1.3/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  - [The `terraform state mv` command](/cli/commands/state/mv) changes
    25    which resource address in your configuration is associated with a particular
    26    real-world object. Use this to preserve an object when renaming a resource, or
    27    when moving a resource into or out of a child module.
    28  
    29    > **Hands On:** Try the [Use Configuration to Move Resources](https://learn.hashicorp.com/tutorials/terraform/move-config) on HashiCorp Learn.
    30  
    31  - [The `terraform state rm` command](/cli/commands/state/rm) tells
    32    Terraform to stop managing a resource as part of the current working directory
    33    and workspace, _without_ destroying the corresponding real-world object. (You
    34    can later use `terraform import` to start managing that resource in a
    35    different workspace or a different Terraform configuration.)
    36  
    37  - [The `terraform state replace-provider` command](/cli/commands/state/replace-provider)
    38    transfers existing resources to a new provider without requiring them to be
    39    re-created.