mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-03-04 08:03:40 -05:00
Signed-off-by: Janos <86970079+janosdebugs@users.noreply.github.com> Signed-off-by: Damian Stasik <920747+damianstasik@users.noreply.github.com> Signed-off-by: Roman Grinovski <roman.grinovski@gmail.com> Co-authored-by: Damian Stasik <920747+damianstasik@users.noreply.github.com> Co-authored-by: Roman Grinovski <roman.grinovski@gmail.com>
51 lines
1.9 KiB
Plaintext
51 lines
1.9 KiB
Plaintext
---
|
|
description: >-
|
|
The `tofu state replace-provider` command replaces the provider for
|
|
resources in the OpenTofu state.
|
|
---
|
|
|
|
# Command: state replace-provider
|
|
|
|
The `tofu state replace-provider` command is used to replace the provider
|
|
for resources in a [OpenTofu state](../../../language/state/index.mdx).
|
|
|
|
## Usage
|
|
|
|
Usage: `tofu 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](../../../cli/cloud/index.mdx) or the [`remote` backend](../../../language/settings/backends/remote.mdx)
|
|
only, `tofu state replace-provider`
|
|
also accepts the option
|
|
[`-ignore-remote-version`](../../../cli/cloud/command-line-arguments.mdx#ignore-remote-version).
|
|
|
|
For configurations using
|
|
[the `local` state](../../../language/settings/backends/local.mdx) only,
|
|
`tofu state replace-provider` also accepts the legacy options
|
|
[`-state`, `-state-out`, and `-backup`](../../../language/settings/backends/local.mdx#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
|
|
$ tofu state replace-provider hashicorp/aws registry.acme.corp/acme/aws
|
|
```
|