Files
opentf/website/docs/cli/state/index.mdx
Martin Atkins beb9432155 website: CLI state manipulation section de-emphasize old features
Previously the "terraform state ..." subcommands were the only way to
perform various manipulations of the state, but in recent Terraform
versions we have replaced these with better options.

Since these pages seem to already have pretty good search engine
optimization for the use-cases they are describing, we'll prioritize
mentioning the new approaches and only mention the now-deprecated or
de-emphasized features as a secondary approach.

Specifically:
 - Describe the -replace=... planning option in preference to
   "terraform taint", and present taint as primarily a mechanism for
   Terraform to use itself, as opposed to something end-users should
   typically use directly.
 - Introduce the config-based refactoring features before describing
   "terraform state mv".

The older features here are still applicable in some situations and are
required for those still using older versions of Terraform, so we will
retain the information about them for now while aiming to be clearer in
each case about which is our preferred, modern approach.
2022-01-11 07:36:20 -08:00

35 lines
1.5 KiB
Plaintext

---
page_title: Manipulating State - Terraform CLI
description: >-
State data tracks which real-world object corresponds to each resource.
Inspect state, move or import resources, and more.
---
# Manipulating Terraform State
> **Hands-on:** Try the [Manage Resources in Terraform State](https://learn.hashicorp.com/tutorials/terraform/state-cli?utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS) tutorial on HashiCorp Learn.
Terraform uses [state data](/language/state) to remember which
real-world object corresponds to each resource in the configuration;
this allows it to modify an existing object when its resource declaration
changes.
Terraform updates state automatically during plans and applies. However, it's
sometimes necessary to make deliberate adjustments to Terraform's state data,
usually to compensate for changes to the configuration or the real managed
infrastructure.
Terraform CLI supports several workflows for interacting with state:
- [Inspecting State](/cli/state/inspect)
- [Forcing Re-creation](/cli/state/taint)
- [Moving Resources](/cli/state/move)
- Importing Pre-existing Resources (documented in the
[Importing Infrastructure](/cli/import) section)
- [Disaster Recovery](/cli/state/recover)
~> **Important:** Modifying state data outside a normal plan or apply can cause
Terraform to lose track of managed resources, which might waste money, annoy
your colleagues, or even compromise the security of your operations. Make sure
to keep backups of your state data when modifying state out-of-band.