github.com/hugorut/terraform@v1.1.3/website/docs/cli/commands/state/replace-provider.mdx (about)

     1  ---
     2  page_title: 'Command: state replace-provider'
     3  description: >-
     4    The `terraform state replace-provider` command replaces the provider for
     5    resources in the Terraform state.
     6  ---
     7  
     8  # Command: state replace-provider
     9  
    10  The `terraform state replace-provider` command is used to replace the provider
    11  for resources in a [Terraform state](/language/state).
    12  
    13  ## Usage
    14  
    15  Usage: `terraform state replace-provider [options] FROM_PROVIDER_FQN TO_PROVIDER_FQN`
    16  
    17  This command will update all resources using the "from" provider, setting the
    18  provider to the specified "to" provider. This allows changing the source of a
    19  provider which currently has resources in state.
    20  
    21  This command will output a backup copy of the state prior to saving any
    22  changes. The backup cannot be disabled. Due to the destructive nature
    23  of this command, backups are required.
    24  
    25  This command also accepts the following options:
    26  
    27  * `-auto-approve` - Skip interactive approval.
    28  
    29  * `-lock=false` - Don't hold a state lock during the operation. This is
    30    dangerous if others might concurrently run commands against the same
    31    workspace.
    32  
    33  * `-lock-timeout=0s` - Duration to retry a state lock.
    34  
    35  For configurations using
    36  [the `remote` backend](/language/settings/backends/remote)
    37  only, `terraform state replace-provider`
    38  also accepts the option
    39  [`-ignore-remote-version`](/language/settings/backends/remote#command-line-arguments).
    40  
    41  For configurations using
    42  [the `local` state rm](/language/settings/backends/local) only,
    43  `terraform state replace-provider` also accepts the legacy options
    44  [`-state`, `-state-out`, and `-backup`](/language/settings/backends/local#command-line-arguments).
    45  
    46  ## Example
    47  
    48  The example below replaces the `hashicorp/aws` provider with a fork by `acme`, hosted at a private registry at `registry.acme.corp`:
    49  
    50  ```shell
    51  $ terraform state replace-provider hashicorp/aws registry.acme.corp/acme/aws
    52  ```