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
@@ -7,138 +7,41 @@ Because v2.x changed how the subnet resource is iterated on, resources in Terraf
7
7
8
8
## Migration Instructions
9
9
10
-
- Upgrade to the new version of this module.
10
+
First, upgrade to the new version of this module.
11
11
12
-
if you run `terraform plan` at this point. Terraform will inform you that it will attempt to delete and recreate your existing subnets. This is almost certainly not the behavior you want. For example:
Note: You didn't specify an "-out" parameter to save this plan, so Terraform
90
-
can't guarantee that exactly these actions will be performed if
91
-
"terraform apply" is subsequently run.
18
+
# ...
19
+
}
92
20
```
93
21
94
-
### Manual Migration Steps
95
-
96
-
In this example here are the commands used migrate the vpc and subnets created by the `simple_project`in the examples directory. _please note the need to escape the quotes on the new resource_. You may also use the migration script.
97
-
98
-
- `terraform state mv module.example.module.test-vpc-module.google_compute_network.network module.example.module.test-vpc-module.module.vpc.google_compute_subnetwork.network`
99
-
100
-
- `terraform state mv module.example.module.test-vpc-module.google_compute_subnetwork.subnetwork module.example.module.test-vpc-module.module.subnets.google_compute_subnetwork.subnetwork`
101
-
102
-
- `terraform state mv module.example.module.test-vpc-module.module.subnets.google_compute_subnetwork.subnetwork[0] module.example.module.test-vpc-module.module.subnets.google_compute_subnetwork.subnetwork[\"us-west1/simple-project-timh-subnet-01\"]`
103
-
104
-
- `terraform state mv module.example.module.test-vpc-module.module.subnets.google_compute_subnetwork.subnetwork[1] module.example.module.test-vpc-module.module.subnets.google_compute_subnetwork.subnetwork[\"us-west1/simple-project-timh-subnet-02\"]`
105
-
106
-
*You'll notice that because of a terraform [issue](https://github.com/hashicorp/terraform/issues/22301), we need to move the whole resource collection first before renaming to the `for_each` keys*
107
-
108
-
`terraform plan` should now return a no-op and show no new changes.
109
-
110
-
```Shell
111
-
$ terraform plan
112
-
Refreshing Terraform state in-memory prior to plan...
113
-
The refreshed state will be used to calculate this plan, but will not be
114
-
persisted to local or remote state storage.
22
+
If you run `terraform plan` at this point, Terraform will inform you that it will attempt to delete and recreate your existing subnets. This is almost certainly not the behavior you want.
2. Run the script to output the migration commands:
139
42
140
43
```sh
141
-
$ ./migrate.py --dry-run
44
+
$ ./migrate.py --dryrun
142
45
terraform state mv 'module.example.module.test-vpc-module-02.google_compute_network.network[0]''module.example.module.test-vpc-module-02.module.vpc.google_compute_network.network'
143
46
terraform state mv 'module.example.module.test-vpc-module-02.google_compute_subnetwork.subnetwork''module.example.module.test-vpc-module-02.module.subnets.google_compute_subnetwork.subnetwork'
144
47
terraform state mv 'module.example.module.test-vpc-module-02.module.subnets.google_compute_subnetwork.subnetwork[0]''module.example.module.test-vpc-module-02.module.subnets.google_compute_subnetwork.subnetwork["us-west1/multi-vpc-a1-02-subnet-01"]'
@@ -149,7 +52,7 @@ actions need to be performed.
149
52
150
53
```
151
54
152
-
3. Execute the migration command
55
+
3. Execute the migration script:
153
56
154
57
```sh
155
58
$ ./migrate.py
@@ -175,6 +78,41 @@ actions need to be performed.
175
78
176
79
4. Run `terraform plan` to confirm no changes are expected.
177
80
81
+
### Manual Migration Steps
82
+
83
+
In this example here are the commands used migrate the vpc and subnets created by the `simple_project`in the examples directory. _please note the need to escape the quotes on the new resource_. You may also use the migration script.
84
+
85
+
- `terraform state mv module.example.module.test-vpc-module.google_compute_network.network module.example.module.test-vpc-module.module.vpc.google_compute_subnetwork.network`
86
+
87
+
- `terraform state mv module.example.module.test-vpc-module.google_compute_subnetwork.subnetwork module.example.module.test-vpc-module.module.subnets.google_compute_subnetwork.subnetwork`
88
+
89
+
- `terraform state mv module.example.module.test-vpc-module.module.subnets.google_compute_subnetwork.subnetwork[0] module.example.module.test-vpc-module.module.subnets.google_compute_subnetwork.subnetwork[\"us-west1/simple-project-timh-subnet-01\"]`
90
+
91
+
- `terraform state mv module.example.module.test-vpc-module.module.subnets.google_compute_subnetwork.subnetwork[1] module.example.module.test-vpc-module.module.subnets.google_compute_subnetwork.subnetwork[\"us-west1/simple-project-timh-subnet-02\"]`
92
+
93
+
*You'll notice that because of a terraform [issue](https://github.com/hashicorp/terraform/issues/22301), we need to move the whole resource collection first before renaming to the `for_each` keys*
94
+
95
+
`terraform plan` should now return a no-op and show no new changes.
96
+
97
+
```Shell
98
+
$ terraform plan
99
+
Refreshing Terraform state in-memory prior to plan...
100
+
The refreshed state will be used to calculate this plan, but will not be
0 commit comments