Files
opentf/website/docs/cli/state/move.html.md
Nick Fagerlund 2c02233a16 website: Add new "glue"/overview pages for CLI and language docs
The new nav structure demanded a few new pages that give context about a feature
or workflow. In a few cases, they take text from an existing page.

Co-authored-by: Tu Nguyen <im2nguyen@users.noreply.github.com>
Co-authored-by: Judith Malnick <judith.patudith@gmail.com>
2020-11-11 19:13:23 -08:00

1.6 KiB

layout, page_title
layout page_title
docs Moving Resources - Terraform CLI

Moving Resources

Terraform's state associates each real-world object with a configured resource at a specific resource address. This is seamless when changing a resource's attributes, but Terraform 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: Terraform 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 Terraform to associate it with a different configured resource.

  • The terraform state mv command 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 terraform state rm command tells Terraform 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 terraform import to start managing that resource in a different workspace or a different Terraform configuration.)

  • The terraform state replace-provider command transfers existing resources to a new provider without requiring them to be re-created.