Files
opentf/website/docs/commands/state/replace-provider.html.md
Nick Fagerlund fa9ad0c5e5 website: Adopt islanded subcommands into unified "docs" (CLI) layout
Several `terraform` subcommands include sub-sub-commands; with our old sidebar
system, viewing those took you to an isolated "island" nav sidebar, away from
the main docs. The new navigation will adopt all these pages, so we don't need
to exile the reader to odd places.
2020-10-26 18:19:46 -07:00

1.7 KiB

layout, page_title, sidebar_current, description
layout page_title sidebar_current description
docs Command: state replace-provider docs-commands-state-sub-replace-provider The `terraform state replace-provider` command replaces the provider for resources in the Terraform state.

Command: state replace-provider

The terraform state replace-provider command is used to replace the provider for resources in a Terraform state.

Usage

Usage: terraform 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.

The command-line flags are all optional. The list of available flags are:

  • -auto-approve - Skip interactive approval.

  • -backup=path - Path where Terraform should write the backup for the original state. This can't be disabled. If not set, Terraform will write it to the same path as the statefile with a ".backup" extension.

  • -lock=true- Lock the state files when locking is supported.

  • -lock-timeout=0s - Duration to retry a state lock.

  • -state=path - Path to the source state file to read from. Defaults to the configured backend, or "terraform.tfstate".

Example

The example below replaces the hashicorp/aws provider with a fork by acme, hosted at a private registry at registry.acme.corp:

$ terraform state replace-provider hashicorp/aws registry.acme.corp/acme/aws