From 52d64127f7c2f2be3edd8ab11b935f11248a1393 Mon Sep 17 00:00:00 2001 From: Alisdair McDiarmid Date: Thu, 23 Apr 2020 11:41:57 -0400 Subject: [PATCH] website: Add docs for state replace-provider --- command/state_replace_provider.go | 3 -- .../commands/state/replace-provider.html.md | 47 +++++++++++++++++++ website/layouts/commands-state.erb | 4 ++ 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 website/docs/commands/state/replace-provider.html.md diff --git a/command/state_replace_provider.go b/command/state_replace_provider.go index 57d1d0385..3d5acf678 100644 --- a/command/state_replace_provider.go +++ b/command/state_replace_provider.go @@ -170,9 +170,6 @@ Usage: terraform state replace-provider [options] FROM_PROVIDER_FQN TO_PROVIDER_ Replace provider for resources in the Terraform state. - An error will be returned if any of the resources or modules given as - filter addresses do not exist in the state. - Options: -auto-approve Skip interactive approval. diff --git a/website/docs/commands/state/replace-provider.html.md b/website/docs/commands/state/replace-provider.html.md new file mode 100644 index 000000000..1219c12a2 --- /dev/null +++ b/website/docs/commands/state/replace-provider.html.md @@ -0,0 +1,47 @@ +--- +layout: "commands-state" +page_title: "Command: state replace-provider" +sidebar_current: "docs-commands-state-sub-replace-provider" +description: |- + 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](/docs/state/index.html). + +## 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`: + +```shell +$ terraform state replace-provider hashicorp/aws registry.acme.corp/acme/aws +``` diff --git a/website/layouts/commands-state.erb b/website/layouts/commands-state.erb index f23aca281..f5a98d329 100644 --- a/website/layouts/commands-state.erb +++ b/website/layouts/commands-state.erb @@ -30,6 +30,10 @@ push + > + replace-provider + + > rm