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
Copy file name to clipboardExpand all lines: content/terraform-docs-common/docs/cloud-docs/migrate/index.mdx
+8-10Lines changed: 8 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,7 @@
1
1
---
2
2
page_title: Migrate Terraform state to HCP Terraform or Terraform Enterprise
3
3
description: >-
4
-
Learn how to migrate existing Terraform state to HCP Terraform or Terraform Enterprise so that you can manage
5
-
existing infrastructure without de-provisioning.
4
+
Learn how to migrate existing Terraform state to HCP Terraform or Terraform Enterprise using the CLI, API, or tf-migrate.
6
5
---
7
6
8
7
# Migrate Terraform state to HCP Terraform or Terraform Enterprise
@@ -14,13 +13,13 @@ This topic describes how to migrate existing Terraform state files to HCP Terraf
14
13
Perform the following actions to migrate existing resources to one or more workspaces in HCP Terraform or Terraform Enterprise:
15
14
16
15
1. Stop all Terraform operations associated with the state files.
17
-
1. Migrate Terraform state files using either the Terraform CLI or the HCP Terraform or Terraform Enterprise API.
16
+
1. Migrate Terraform state files to HCP Terraform or Terraform Enterprise.
18
17
19
18
You have three options to migrate your state:
20
19
21
20
1. Manually using the Terraform CLI
22
-
1. Automatically using `tf-migrate`
23
21
1. Manually using the HCP Terraform API
22
+
1. Automatically using `tf-migrate`
24
23
25
24
## Requirements
26
25
@@ -60,10 +59,6 @@ Stop all Terraform operations associated with the state files. This may require
60
59
61
60
1. Run `terraform init`. Terraform creates any workspaces specified in the configuration if they do not already exist in the organization.
62
61
63
-
## Migrate state using Terraform migrate
64
-
65
-
You can use the Terraform migrate CLI tool to automatically migrate state to HCP Terraform and Terraform Enterprise. The tool does not ship with HCP Terraform. You must download and install the binary for the CLI tool separately. Refer to the [Terraform migrate documentation](/terraform/migrate) for more information.
66
-
67
62
## Migrate state using the API
68
63
69
64
1. Encode your state files as a base64 string and generate an MD5 hash. The following example generates the string and hash file for a single `terraform.tfstate` file:
@@ -89,6 +84,9 @@ You can use the Terraform migrate CLI tool to automatically migrate state to HCP
89
84
Refer to the following external article for an example of how to create a script in Python to automate multiple state files:
90
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.
91
86
92
-
## Migrate state using Terraform migrate
93
87
94
-
You can use the Terraform migrate CLI tool to automatically migrate state to HCP Terraform and Terraform Enterprise. The tool does not ship with HCP Terraform. You must download and install the binary for the CLI tool separately. Refer to the [Terraform migrate documentation](/terraform/cloud-docs/migrate/tf-migrate) for more information.
88
+
## Migrate state using `tf-migrate`
89
+
90
+
> **Hands-on:** Complete the [Migrate to HCP Terraform in bulk](/terraform/tutorials/cloud/bulk-migrate-hcp) tutorial to get started with tf-migrate.
91
+
92
+
You can use the `tf-migrate` CLI tool to automatically migrate state to HCP Terraform and Terraform Enterprise. The tool does not ship with HCP Terraform. You must download and install the binary for the CLI tool separately. Refer to the [`tf-migrate` documentation](/terraform/migrate) for more information.
0 commit comments