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-migrate/v2.0.x/docs/migrate/index.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,7 +52,7 @@ If your local configuration does not meet all of the above requirements, `tf-mig
52
52
53
53
@include "stacks.mdx"
54
54
55
-
The `tf-migrate` CLI can migrate Terraform configuration and state from an HCP Terraform workspace to a Stack. Refer to [Migrate a workspace to a Stack](/terraform/migrate/stacks) for more information.
55
+
The `tf-migrate` CLI can migrate Terraform configuration and state from one or more HCP Terraform workspaces to a Stack. Refer to [Migrate workspaces to a Stack](/terraform/migrate/stacks) for more information.
Copy file name to clipboardExpand all lines: content/terraform-migrate/v2.0.x/docs/migrate/reference/cli/stacks/prepare.mdx
+64-12Lines changed: 64 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ description: >-
6
6
7
7
# `tf-migrate stacks prepare` reference
8
8
9
-
The `tf-migrate stacks prepare` generates new Terraform configuration to migrate your HCP Terraform workspace to a Stack.
9
+
The `tf-migrate stacks prepare` generates new Terraform configuration to migrate one or more HCP Terraform workspaces to a Stack.
10
10
11
11
@include "stacks.mdx"
12
12
@@ -23,23 +23,60 @@ The `tf-migrate stacks prepare` command prompts you for the following informatio
23
23
- A name for the Stack.
24
24
- A name for the new project to deploy the Stack to. This project must not already exist.
25
25
26
-
The `tf-migrate prepare` command copies your configuration and local modules to create a new Terraform Stack configuration in the `_stacks_generated` directory. It also generated Terraform configuration to perform the migration in the `stacks_migration_infra` directory.
26
+
The `tf-migrate prepare` command copies your configuration and local modules to create a new Terraform Stack configuration in the `_stacks_generated` directory. It also generates Terraform configuration to perform the migration in the `stacks_migration_infra` directory.
27
27
28
-
This command does not change your existing configuration.
28
+
This command does not change your existing configuration, state, or deployed resources.
29
+
30
+
The `tf-migrate stacks prepare` command creates one Stack `deployment` block for each HCP Terraform workspace the configuration manages. If your configuration's `cloud` block targets a single workspace with the `workspaces.name` argument, `tf-migrate` creates one Stack deployment. If your configuration's `cloud` block targets multiple workspaces with the `workspaces.tags` argument, `tf-migrate` creates a Stack deployment for each workspace that matches those tags.
31
+
32
+
The following is an example is a `terraform` block that defines two tags, one named `environment` and another named `application`.
33
+
34
+
```hcl
35
+
terraform {
36
+
cloud {
37
+
organization = "<ORG_NAME>"
38
+
workspaces {
39
+
tags = {
40
+
"environment" = "development"
41
+
"application" = "web"
42
+
}
43
+
}
44
+
}
45
+
}
46
+
```
47
+
48
+
If this example matches two workspaces, `tf-migrate` creates two `deployment` blocks in the `_stacks_generated/deployment.tfdeploy.hcl` file and names them to match the workspace name.
49
+
50
+
```hcl
51
+
deployment "web-dev-east" {
52
+
inputs = {
53
+
##...
54
+
}
55
+
import = true
56
+
}
57
+
58
+
59
+
60
+
deployment "web-dev-west" {
61
+
inputs = {
62
+
##...
63
+
}
64
+
import = true
65
+
}
66
+
```
29
67
30
68
## Example
31
69
32
70
The `tf-migrate stacks prepare` command generates the configuration to migrate this HCP Terraform workspace to a Stack. The following example creates a Stack named `my-new-stack` in the `my-project` project.
33
71
34
72
```
35
73
$ tf-migrate stacks prepare
36
-
tf-migrate stacks prepare
37
74
✓ Environment readiness checks completed
38
75
✓ Extracted terraform configuration data from current directory
39
-
Enter the name of the stack to be created: my-new-stack
40
-
Enter the name of the project under which stack is to be created: my-project
41
-
✓ Fetched latest state file for workspace: already-modular
42
-
✓ Parsed state file for workspace: already-modular
76
+
Enter the name of the stack to be created: my-stack
77
+
Enter the name of a new project under which the stack will be created (project must not already exist): my-stack-proj
78
+
✓ Fetched latest state file for workspace: my-workspace
79
+
✓ Parsed state file for workspace: my-workspace
43
80
✓ Extracted variables from terraform configuration
44
81
✓ Extracted providers from terraform configuration
45
82
✓ Extracted outputs blocks from terraform configuration
@@ -50,10 +87,25 @@ Enter the name of the project under which stack is to be created: my-project
0 commit comments