You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an automated pull request to sync changes between the public and
private unified docs repos.
To preserve continuity across repos, _do not squash_ this pull request.
Copy file name to clipboardExpand all lines: content/terraform-docs-common/docs/cloud-docs/migrate/index.mdx
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,13 @@ description: >-
6
6
7
7
# Migrate Terraform state to HCP Terraform or Terraform Enterprise
8
8
9
-
This topic describes how to migrate existing Terraform state files to HCP Terraform or Terraform Enterprise without first de-provisioning them. Refer to [State](/terraform/language/state) in the Terraform configuration language reference for additional information about Terraform state.
9
+
This topic describes how to migrate existing Terraform state files to HCP Terraform or Terraform Enterprise without first de-provisioning them. Refer to [State](/terraform/language/state) in the Terraform configuration language reference for additional information about Terraform state.
10
10
11
11
## Overview
12
12
13
13
Perform the following actions to migrate existing resources to one or more workspaces in HCP Terraform or Terraform Enterprise:
14
14
15
-
1. Stop all Terraform operations associated with the state files.
15
+
1. Stop all Terraform operations associated with the state files.
16
16
1. Migrate Terraform state files to HCP Terraform or Terraform Enterprise.
17
17
18
18
You have three options to migrate your state:
@@ -39,9 +39,9 @@ Stop all Terraform operations associated with the state files. This may require
39
39
40
40
41
41
1. Add the `cloud` block to your Terraform configuration and specify the following fields:
42
-
1.`hostname` field: Specify either `app.terraform.io` for HCP Terraform or the hostname of your Terraform Enterprise deployment.
43
-
1.`organization` field: Specify your HCP Terraform or Terraform Enterprise organization.
44
-
1.`workspaces` block: Add a `tags` or `name` field and specify one or more destination workspaces as a list of strings.
42
+
1.`hostname` field: Specify either `app.terraform.io` for HCP Terraform or the hostname of your Terraform Enterprise deployment.
43
+
1.`organization` field: Specify your HCP Terraform or Terraform Enterprise organization.
44
+
1.`workspaces` block: Add a `tags` or `name` field and specify one or more destination workspaces as a list of strings.
45
45
46
46
Refer to [The `cloud` Block](/terraform/cli/cloud/settings#the-cloud-block) in the Terraform CLI documentation for additional information. The following example migrates the state associated with the configuration to the `networking` workspace on HCP Terraform:
47
47
@@ -69,17 +69,17 @@ Stop all Terraform operations associated with the state files. This may require
1. If the workspace does not yet exist in your organization, send a `POST` request to the `/organizations/:organization_name/workspaces` endpoint to create it. Otherwise, proceed to the next step. Refer to the following topics for details:
74
-
-[Create a workspace](/terraform/cloud-docs/api-docs/workspaces#create-a-workspace) in the HCP Terraform API reference documentation.
74
+
-[Create a workspace](/terraform/cloud-docs/api-docs/workspaces#create-a-workspace) in the HCP Terraform API reference documentation.
75
75
-[Create a workspace](/terraform/enterprise/api-docs/workspaces#create-a-workspace) in the Terraform Enterprise API reference documentation.
76
76
1. Send a `POST` request to the `/workspaces/:workspace_id/actions/lock` endpoint to lock the workspace. Refer to the following topics for details:
77
-
-[Lock a workspace](/terraform/cloud-docs/api-docs/workspaces#lock-a-workspace) in the HCP Terraform API reference documentation.
78
-
-[Lock a workspace](/terraform/enterprise/api-docs/workspaces#lock-a-workspace) in the Terraform Enterprise API reference documentation.
77
+
-[Lock a workspace](/terraform/cloud-docs/api-docs/workspaces#lock-a-workspace) in the HCP Terraform API reference documentation.
78
+
-[Lock a workspace](/terraform/enterprise/api-docs/workspaces#lock-a-workspace) in the Terraform Enterprise API reference documentation.
79
79
1. To upload your state files to the workspace, send a `POST` request to the `/workspaces/:workspace_id/state-versions` endpoint. Specify the MD5 string in the `data.attributes.md5` field and encoded state file in the `data.attributes.state` field of the request body. Refer to the following topics for details:
80
-
-[Create a state version](/terraform/cloud-docs/api-docs/state-versions#create-a-state-version) in the HCP Terraform API reference documentation.
80
+
-[Create a state version](/terraform/cloud-docs/api-docs/state-versions#create-a-state-version) in the HCP Terraform API reference documentation.
81
81
-[Create a state version](/terraform/enterprise/api-docs/state-versions#create-a-state-version) in the Terraform Enterprise API reference documentation.
82
-
1. Send a `POST` request to the `/workspaces/:workspace_id/actions/unlock` endpoint to unlock the workspace.
82
+
1. Send a `POST` request to the `/workspaces/:workspace_id/actions/unlock` endpoint to unlock the workspace.
83
83
84
84
Refer to the following external article for an example of how to create a script in Python to automate multiple state files:
85
85
[Migrating A Lot of State with Python and the HCP Terraform (previously Terraform Cloud) API](https://medium.com/hashicorp-engineering/migrating-a-lot-of-state-with-python-and-the-terraform-cloud-api-997ec798cd11). The example uses the [Workspaces API](/terraform/cloud-docs/api-docs/workspaces#create-a-workspace) to create the necessary workspaces in HCP Terraform and the [State Versions API](/terraform/cloud-docs/api-docs/state-versions) to migrate the state files to those workspaces.
0 commit comments