Files
opentf/website/docs/cli/commands/state/replace-provider.mdx
Kuba Martin 4d665a0091 Update website/docs/cli. (#171)
* Initial renaming, rewriting and cleaning up wave for the CLI docs.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* More renaming.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* More renaming.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* More renaming.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Remove tutorial references.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Post-review fixes.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

---------

Signed-off-by: Jakub Martin <kubam@spacelift.io>
2023-08-25 11:09:18 +02:00

52 lines
1.9 KiB
Plaintext

---
page_title: 'Command: state replace-provider'
description: >-
The `opentf state replace-provider` command replaces the provider for
resources in the OpenTF state.
---
# Command: state replace-provider
The `opentf state replace-provider` command is used to replace the provider
for resources in a [OpenTF state](/opentf/language/state).
## Usage
Usage: `opentf state replace-provider [options] FROM_PROVIDER_FQN TO_PROVIDER_FQN`
This command will update all resources using the "from" provider, setting the
provider to the specified "to" provider. This allows changing the source of a
provider which currently has resources in state.
This command will output a backup copy of the state prior to saving any
changes. The backup cannot be disabled. Due to the destructive nature
of this command, backups are required.
This command also accepts the following options:
- `-auto-approve` - Skip interactive approval.
- `-lock=false` - Don't hold a state lock during the operation. This is
dangerous if others might concurrently run commands against the same
workspace.
- `-lock-timeout=0s` - Duration to retry a state lock.
For configurations using the [`cloud` backend](/opentf/cli/cloud) or the [`remote` backend](/opentf/language/settings/backends/remote)
only, `opentf state replace-provider`
also accepts the option
[`-ignore-remote-version`](/opentf/cli/cloud/command-line-arguments#ignore-remote-version).
For configurations using
[the `local` state](/opentf/language/settings/backends/local) only,
`opentf state replace-provider` also accepts the legacy options
[`-state`, `-state-out`, and `-backup`](/opentf/language/settings/backends/local#command-line-arguments).
## Example
The example below replaces the `hashicorp/aws` provider with a fork by `acme`, hosted at a private registry at `registry.acme.corp`:
```shell
$ opentf state replace-provider hashicorp/aws registry.acme.corp/acme/aws
```