You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
terraform/website/docs/cli/commands/state/index.mdx

55 lines
2.1 KiB

---
page_title: terraform state commands reference
description: The `terraform state` group of commands enable advanced Terraform state management.
---
# `terraform state` commands
The `terraform state` commands enable advanced state management.
## Introduction
You can use the `terraform state` commands to modify the [Terraform state](/terraform/language/state) instead modifying the state directly.
## Usage
Usage: `terraform state <subcommand> [options] [args]`
Refer to the following subcommands for additional information:
- [`terraform state list`](/terraform/cli/commands/state/list)
- [`terraform state mv`](/terraform/cli/commands/state/mv)
- [`terraform state pull`](/terraform/cli/commands/state/pull)
- [`terraform state replace-provider`](/terraform/cli/commands/state/replace-provider)
- [`terraform state rm`](/terraform/cli/commands/state/rm)
- [`terraform state show`](/terraform/cli/commands/state/show)
## Remote State
The Terraform state subcommands all work with remote state just as if it
was local state. Reads and writes may take longer than normal as each read
and each write do a full network roundtrip. Otherwise, backups are still
written to disk and the CLI usage is the same as if it were local state.
## Backups
All `terraform state` subcommands that modify the state write backup
files. The path of these backup file can be controlled with `-backup`.
Subcommands that are read-only (such as [list](/terraform/cli/commands/state/list))
do not write any backup files since they aren't modifying the state.
Note that backups for state modification _can not be disabled_. Due to
the sensitivity of the state file, Terraform forces every state modification
command to write a backup file. You'll have to remove these files manually
if you don't want to keep them around.
## Command-Line Friendly
The output and command-line structure of the state subcommands is
designed to be usable with Unix command-line tools such as grep, awk,
and similar PowerShell commands.
For advanced filtering and modification, we recommend piping Terraform
state subcommands together with other command line tools.