Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

website: Add docs for state replace-provider #24752

Merged
merged 1 commit into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions command/state_replace_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
47 changes: 47 additions & 0 deletions website/docs/commands/state/replace-provider.html.md
Original file line number Diff line number Diff line change
@@ -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
```
4 changes: 4 additions & 0 deletions website/layouts/commands-state.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
<a href="/docs/commands/state/push.html">push</a>
</li>

<li<%= sidebar_current("docs-commands-state-sub-replace-provider") %>>
<a href="/docs/commands/state/replace-provider.html">replace-provider</a>
</li>

<li<%= sidebar_current("docs-commands-state-sub-rm") %>>
<a href="/docs/commands/state/rm.html">rm</a>
</li>
Expand Down