mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
migrate docs to mdx
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
---
|
||||
layout: "docs"
|
||||
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."
|
||||
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](/docs/language/state/index.html) to remember which
|
||||
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.
|
||||
@@ -20,12 +21,12 @@ infrastructure.
|
||||
|
||||
Terraform CLI supports several workflows for interacting with state:
|
||||
|
||||
- [Inspecting State](/docs/cli/state/inspect.html)
|
||||
- [Forcing Re-creation (Tainting)](/docs/cli/state/taint.html)
|
||||
- [Moving Resources](/docs/cli/state/move.html)
|
||||
- [Inspecting State](/cli/state/inspect)
|
||||
- [Forcing Re-creation (Tainting)](/cli/state/taint)
|
||||
- [Moving Resources](/cli/state/move)
|
||||
- Importing Pre-existing Resources (documented in the
|
||||
[Importing Infrastructure](/docs/cli/import/index.html) section)
|
||||
- [Disaster Recovery](/docs/cli/state/recover.html)
|
||||
[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
|
||||
@@ -1,7 +1,6 @@
|
||||
---
|
||||
layout: "docs"
|
||||
page_title: "Inspecting State - Terraform CLI"
|
||||
description: "Commands that allow you to read and update state."
|
||||
page_title: Inspecting State - Terraform CLI
|
||||
description: Commands that allow you to read and update state.
|
||||
---
|
||||
|
||||
# Inspecting State
|
||||
@@ -9,14 +8,14 @@ description: "Commands that allow you to read and update state."
|
||||
Terraform includes some commands for reading and updating state without taking
|
||||
any other actions.
|
||||
|
||||
- [The `terraform state list` command](/docs/cli/commands/state/list.html)
|
||||
- [The `terraform state list` command](/cli/commands/state/list)
|
||||
shows the resource addresses for every resource Terraform knows about in a
|
||||
configuration, optionally filtered by partial resource address.
|
||||
|
||||
- [The `terraform state show` command](/docs/cli/commands/state/show.html)
|
||||
- [The `terraform state show` command](/cli/commands/state/show)
|
||||
displays detailed state data about one resource.
|
||||
|
||||
- [The `terraform refresh` command](/docs/cli/commands/refresh.html) updates
|
||||
- [The `terraform refresh` command](/cli/commands/refresh) updates
|
||||
state data to match the real-world condition of the managed resources. This is
|
||||
done automatically during plans and applies, but not when interacting with
|
||||
state directly.
|
||||
@@ -1,13 +1,14 @@
|
||||
---
|
||||
layout: "docs"
|
||||
page_title: "Moving Resources - Terraform CLI"
|
||||
description: "Commands that allow you to manage the way that resources are tracked in state. They are helpful when you move or change resources."
|
||||
page_title: Moving Resources - Terraform CLI
|
||||
description: >-
|
||||
Commands that allow you to manage the way that resources are tracked in state.
|
||||
They are helpful when you move or change resources.
|
||||
---
|
||||
|
||||
# Moving Resources
|
||||
|
||||
Terraform's state associates each real-world object with a configured resource
|
||||
at a specific [resource address](/docs/cli/state/resource-addressing.html). This
|
||||
at a specific [resource address](/cli/state/resource-addressing). 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.
|
||||
@@ -20,19 +21,19 @@ 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](/docs/cli/commands/state/mv.html) changes
|
||||
- [The `terraform state mv` command](/cli/commands/state/mv) 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.
|
||||
|
||||
> **Hands On:** Try the [Use Configuration to Move Resources](https://learn.hashicorp.com/tutorials/terraform/move-config) on HashiCorp Learn.
|
||||
> **Hands On:** Try the [Use Configuration to Move Resources](https://learn.hashicorp.com/tutorials/terraform/move-config) on HashiCorp Learn.
|
||||
|
||||
- [The `terraform state rm` command](/docs/cli/commands/state/rm.html) tells
|
||||
- [The `terraform state rm` command](/cli/commands/state/rm) 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](/docs/cli/commands/state/replace-provider.html)
|
||||
- [The `terraform state replace-provider` command](/cli/commands/state/replace-provider)
|
||||
transfers existing resources to a new provider without requiring them to be
|
||||
re-created.
|
||||
@@ -1,7 +1,8 @@
|
||||
---
|
||||
layout: "docs"
|
||||
page_title: "Recovering from State Disasters - Terraform CLI"
|
||||
descriptin: "Commands that allow you to restore state backups and override Terraform state protections."
|
||||
page_title: Recovering from State Disasters - Terraform CLI
|
||||
descriptin: >-
|
||||
Commands that allow you to restore state backups and override Terraform state
|
||||
protections.
|
||||
---
|
||||
|
||||
# Recovering from State Disasters
|
||||
@@ -10,7 +11,7 @@ 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.
|
||||
|
||||
- [The `terraform force-unlock` command](/docs/cli/commands/force-unlock.html) can
|
||||
- [The `terraform force-unlock` command](/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
|
||||
@@ -18,8 +19,7 @@ your state data.
|
||||
state backend. Do not run this until you are completely certain what happened
|
||||
to the process that caused the lock to get stuck.
|
||||
|
||||
- [The `terraform state pull` command](/docs/cli/commands/state/pull.html) and
|
||||
[the `terraform state push` command](/docs/cli/commands/state/push.html) can
|
||||
- [The `terraform state pull` command](/cli/commands/state/pull) and
|
||||
[the `terraform state push` command](/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.
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
---
|
||||
layout: "docs"
|
||||
page_title: "Internals: Resource Address"
|
||||
sidebar_current: "docs-internals-resource-addressing"
|
||||
page_title: 'Internals: Resource Address'
|
||||
description: |-
|
||||
A resource address is a string that identifies zero or more resource
|
||||
instances in your overall configuration.
|
||||
@@ -32,12 +30,12 @@ A module path addresses a module within the tree of modules. It takes the form:
|
||||
module.module_name[module index]
|
||||
```
|
||||
|
||||
* `module` - Module keyword indicating a child module (non-root). Multiple `module`
|
||||
keywords in a path indicate nesting.
|
||||
* `module_name` - User-defined name of the module.
|
||||
* `[module index]` - (Optional) [Index](#index-values-for-modules-and-resources)
|
||||
to select an instance from a module call that has multiple instances,
|
||||
surrounded by square bracket characters (`[` and `]`).
|
||||
- `module` - Module keyword indicating a child module (non-root). Multiple `module`
|
||||
keywords in a path indicate nesting.
|
||||
- `module_name` - User-defined name of the module.
|
||||
- `[module index]` - (Optional) [Index](#index-values-for-modules-and-resources)
|
||||
to select an instance from a module call that has multiple instances,
|
||||
surrounded by square bracket characters (`[` and `]`).
|
||||
|
||||
An address without a resource spec, i.e. `module.foo` applies to every resource within
|
||||
the module if a single module, or all instances of a module if a module has multiple instances.
|
||||
@@ -64,11 +62,11 @@ It has the following syntax:
|
||||
resource_type.resource_name[instance index]
|
||||
```
|
||||
|
||||
* `resource_type` - Type of the resource being addressed.
|
||||
* `resource_name` - User-defined name of the resource.
|
||||
* `[instance index]` - (Optional) [Index](#index-values-for-modules-and-resources)
|
||||
to select an instance from a resource that has multiple instances,
|
||||
surrounded by square bracket characters (`[` and `]`).
|
||||
- `resource_type` - Type of the resource being addressed.
|
||||
- `resource_name` - User-defined name of the resource.
|
||||
- `[instance index]` - (Optional) [Index](#index-values-for-modules-and-resources)
|
||||
to select an instance from a resource that has multiple instances,
|
||||
surrounded by square bracket characters (`[` and `]`).
|
||||
|
||||
-> In Terraform v0.12 and later, a resource spec without a module path prefix
|
||||
matches only resources in the root module. In earlier versions, a resource spec
|
||||
@@ -79,12 +77,12 @@ in any descendent module.
|
||||
|
||||
The following specifications apply to index values on modules and resources with multiple instances:
|
||||
|
||||
* `[N]` where `N` is a `0`-based numerical index into a resource with multiple
|
||||
instances specified by the `count` meta-argument. Omitting an index when
|
||||
addressing a resource where `count > 1` means that the address references
|
||||
all instances.
|
||||
* `["INDEX"]` where `INDEX` is a alphanumerical key index into a resource with
|
||||
multiple instances specified by the `for_each` meta-argument.
|
||||
- `[N]` where `N` is a `0`-based numerical index into a resource with multiple
|
||||
instances specified by the `count` meta-argument. Omitting an index when
|
||||
addressing a resource where `count > 1` means that the address references
|
||||
all instances.
|
||||
- `["INDEX"]` where `INDEX` is a alphanumerical key index into a resource with
|
||||
multiple instances specified by the `for_each` meta-argument.
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
---
|
||||
layout: "docs"
|
||||
page_title: "Forcing Re-creation of Resources (Tainting) - Terraform CLI"
|
||||
description: "Commands that allow you to destroy and re-create resources manually."
|
||||
page_title: Forcing Re-creation of Resources (Tainting) - Terraform CLI
|
||||
description: Commands that allow you to destroy and re-create resources manually.
|
||||
---
|
||||
|
||||
# Forcing Re-creation of Resources (Tainting)
|
||||
@@ -17,10 +16,10 @@ happen during creation; for example, a virtual machine that configures itself
|
||||
with `cloud-init` on startup might no longer meet your needs if the cloud-init
|
||||
configuration changes.
|
||||
|
||||
- [The `terraform taint` command](/docs/cli/commands/taint.html) tells Terraform to
|
||||
- [The `terraform taint` command](/cli/commands/taint) tells Terraform to
|
||||
destroy and re-create a particular resource during the next apply, regardless
|
||||
of whether its resource arguments would normally require that.
|
||||
|
||||
- [The `terraform untaint` command](/docs/cli/commands/untaint.html) undoes a
|
||||
- [The `terraform untaint` command](/cli/commands/untaint) undoes a
|
||||
previous taint, or can preserve a resource that was automatically tainted due
|
||||
to failed [provisioners](/docs/language/resources/provisioners/syntax.html).
|
||||
to failed [provisioners](/language/resources/provisioners/syntax).
|
||||
Reference in New Issue
Block a user