mirror of https://github.com/hashicorp/terraform
parent
2608a993ce
commit
89e96fa226
@ -1,12 +0,0 @@
|
||||
---
|
||||
page_title: 'Command: env'
|
||||
description: >-
|
||||
The terraform env command is a deprecated form of the terraform workspace
|
||||
command.
|
||||
---
|
||||
|
||||
# Command: env
|
||||
|
||||
The `terraform env` command is deprecated.
|
||||
[The `terraform workspace` command](/terraform/cli/commands/workspace)
|
||||
should be used instead.
|
||||
@ -1,34 +1,32 @@
|
||||
---
|
||||
page_title: Manipulating State - Terraform CLI
|
||||
page_title: Update Terraform state manually
|
||||
description: >-
|
||||
State data tracks which real-world object corresponds to each resource.
|
||||
Inspect state, move or import resources, and more.
|
||||
State data is the record of how real-world objects map to resources in the Terraform configuration. Learn how to manually update with state data.
|
||||
---
|
||||
|
||||
# Manipulating Terraform State
|
||||
# Update Terraform state manually overview
|
||||
|
||||
This topic provides overview information about how to manually update state in Terraform.
|
||||
|
||||
> **Hands-on:** Try the [Manage Resources in Terraform State](/terraform/tutorials/state/state-cli?utm_source=WEBSITE&utm_medium=WEB_IO&utm_offer=ARTICLE_PAGE&utm_content=DOCS) tutorial.
|
||||
|
||||
Terraform uses [state data](/terraform/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](/terraform/cli/state/inspect)
|
||||
- [Forcing Re-creation](/terraform/cli/state/taint)
|
||||
- [Moving Resources](/terraform/cli/state/move)
|
||||
- Importing Pre-existing Resources (documented in the
|
||||
[Importing Infrastructure](/terraform/cli/import) section)
|
||||
- [Disaster Recovery](/terraform/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.
|
||||
## Introduction
|
||||
|
||||
Terraform stores information about real-world object that correspond to resources in the configuration as [state data](/terraform/language/state).
|
||||
Doing so allows Terraform to modify an existing object when its resource declaration changes.
|
||||
|
||||
Terraform automatically updates state when you run the `terraform plan` and `terraform apply` commands, but you may need to manually adjustment state data as a result of changes to the configuration or the real managed infrastructure.
|
||||
|
||||
## Workflow
|
||||
|
||||
Modifying state data outside of normal `terraform plan` or `terraform apply` operations can cause Terraform to lose track of managed resources, leading to increased costs, reduced productivity, or compromised security. Make sure to keep backups of your state data if you choose to manually modify state.
|
||||
|
||||
You can use the Terraform CLI to perform the following state interations:
|
||||
|
||||
- [Inspect state](/terraform/cli/state/inspect)
|
||||
- [Re-create resources](/terraform/cli/state/taint)
|
||||
- [Move resources](/terraform/cli/state/move)
|
||||
- [Import existing resources](/terraform/cli/import)
|
||||
- [Recover state from backup](/terraform/cli/state/recover)
|
||||
|
||||
|
||||
|
||||
@ -1,25 +1,19 @@
|
||||
---
|
||||
page_title: Recovering from State Disasters - Terraform CLI
|
||||
page_title: Recover state from backup overview
|
||||
description: >-
|
||||
Learn how to restore state backups and override Terraform state protections to fix state errors with the Terraform CLI.
|
||||
|
||||
---
|
||||
|
||||
# Recovering from State Disasters
|
||||
# Recover state from backup overview
|
||||
|
||||
This topic provides overview information about recovering Terraform state from a backup after a disaster, such as an accident when performing
|
||||
other state manipulation actions.
|
||||
|
||||
If something has gone horribly wrong (possibly due to accidents when performing
|
||||
other state manipulation actions), you might need to take drastic actions with
|
||||
your state data.
|
||||
## Workflow
|
||||
|
||||
- [The `terraform force-unlock` command](/terraform/cli/commands/force-unlock) can
|
||||
override the protections Terraform uses to prevent two processes from
|
||||
modifying state at the same time. You might need this if a Terraform process
|
||||
(like a normal apply) is unexpectedly terminated (like by the complete
|
||||
destruction of the VM it's running in) before it can release its lock on the
|
||||
state backend. Do not run this until you are completely certain what happened
|
||||
to the process that caused the lock to get stuck.
|
||||
1. **Unlock Terraform**: You may need to unlock Terraform when a `terraform apply` or other process unexpectedly terminates before Terraform can release its lock on the state backend. Unlocking Terraform overrides protectionsthat prevent two processes from modifying state at the same time. We do not recommend unlocking until you determine what caused the lock to get stuck.
|
||||
|
||||
- [The `terraform state pull` command](/terraform/cli/commands/state/pull) and
|
||||
[the `terraform state push` command](/terraform/cli/commands/state/push) can
|
||||
directly read and write entire state files from and to the configured backend.
|
||||
You might need this for obtaining or restoring a state backup.
|
||||
Refer to the [`terraform force-unlock` command](/terraform/cli/commands/force-unlock) documentation for additional information.
|
||||
|
||||
1. **Read state data**: Run the [`terraform state pull` command](/terraform/cli/commands/state/pull) to read the state files from the configured backend.
|
||||
1. **Write state data**: Run the [`terraform state push` command](/terraform/cli/commands/state/push) to write state files to the configured backend.
|
||||
Loading…
Reference in new issue