Skip to content

Commit 2b8b2b3

Browse files
authored
fix!: make project_id and region as required input for instance_template (#455)
1 parent 0c9d75b commit 2b8b2b3

File tree

22 files changed

+87
-11
lines changed

22 files changed

+87
-11
lines changed

docs/upgrading_to_mig_v13.0.md

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1-
# Upgrading to MIG v13.0
1+
# Upgrading to v13.0
22

3-
The v13.0 release of MIG is a backwards incompatible release. Now the `project_id` is required input variable. Earlier it was set to `null` by default. But the `terraform plan` would fail because `google_compute_zones` data block requires a non-null `project_id`.
3+
The v13.0 release of MIG and instance_template is a backwards incompatible release.
4+
5+
## `modules/mig` and `modules/mig_with_percent`
6+
7+
Now the `project_id` is required input variable. Earlier it was set to `null` by default. But the `terraform plan` would fail because `google_compute_zones` data block requires a non-null `project_id`.
48
Users might be bypassing this by setting project at provider level and not providing `project_id` for mig module.
59

10+
## `modules/instance_template` and `modules/preemptible_and_regular_instance_templates`
11+
12+
* Now the `project_id` and `region` is required input variable. Earlier it was set to `null` by default.
13+
14+
615
## Migration Instructions
716

8-
### Explicitly provide project_id as input to the MIG module
17+
### Explicitly provide project_id as input to the MIG modules
918

1019
Users would need to provide project_id explicitly while using v13.0 of mig/mig_with_percent.
1120

@@ -14,7 +23,7 @@ For mig,
1423
```diff
1524
module "mig" {
1625
source = "terraform-google-modules/vm/google//modules/mig"
17-
version = "~> 12.0"
26+
version = "~> 13.0"
1827

1928
+ project_id = var.project_id
2029
region = var.region
@@ -29,7 +38,7 @@ For mig_with_percent,
2938
```diff
3039
module "mig_with_percent" {
3140
source = "terraform-google-modules/vm/google//modules/mig_with_percent"
32-
version = "~> 12.0"
41+
version = "~> 13.0"
3342

3443
+ project_id = var.project_id
3544
region = var.region
@@ -40,3 +49,43 @@ module "mig_with_percent" {
4049
next_version_percent = 50
4150
}
4251
```
52+
53+
### Explicitly provide project_id/region as input to the instance_template modules
54+
55+
For instance_template,
56+
57+
```diff
58+
module "instance_template" {
59+
source = "terraform-google-modules/vm/google//modules/instance_template"
60+
version = "~> 13.0"
61+
62+
+ project_id = var.project_id
63+
+ region = var.region
64+
subnetwork = var.subnetwork
65+
stack_type = "IPV4_ONLY"
66+
service_account = var.service_account
67+
name_prefix = "simple"
68+
tags = var.tags
69+
labels = var.labels
70+
access_config = [local.access_config]
71+
enable_nested_virtualization = var.enable_nested_virtualization
72+
threads_per_core = var.threads_per_core
73+
}
74+
```
75+
76+
For preemptible_and_regular_instance_templates
77+
78+
```diff
79+
module "preemptible_and_regular_instance_templates" {
80+
source = "terraform-google-modules/vm/google//modules/preemptible_and_regular_instance_templates"
81+
version = "~> 13.0"
82+
83+
subnetwork = var.subnetwork
84+
+ project_id = var.project_id
85+
+ region = var.region
86+
service_account = var.service_account
87+
name_prefix = "pvm-and-regular-simple"
88+
tags = var.tags
89+
labels = var.labels
90+
}
91+
```

examples/instance_template/additional_disks/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ module "instance_template" {
2525
version = "~> 12.0"
2626

2727
project_id = var.project_id
28+
region = var.region
2829
subnetwork = var.subnetwork
2930
service_account = var.service_account
3031
name_prefix = "additional-disks"

examples/instance_template/alias_ip_range/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module "instance_template" {
2929
version = "~> 12.0"
3030

3131
project_id = var.project_id
32+
region = var.region
3233
subnetwork = var.subnetwork
3334
service_account = var.service_account
3435
name_prefix = "alias-ip-range"

examples/instance_template/encrypted_disks/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ module "instance_template" {
4040
version = "~> 12.0"
4141

4242
project_id = var.project_id
43+
region = var.region
4344
subnetwork = var.subnetwork
4445
service_account = var.service_account
4546
name_prefix = "additional-disks"

examples/instance_template/simple/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ module "instance_template" {
3636
version = "~> 12.0"
3737

3838
project_id = var.project_id
39+
region = var.region
3940
subnetwork = var.subnetwork
4041
stack_type = "IPV4_ONLY"
4142
service_account = var.service_account

examples/mig/autoscaler/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module "instance_template" {
3131
version = "~> 12.0"
3232

3333
project_id = var.project_id
34+
region = var.region
3435
subnetwork = var.subnetwork
3536
service_account = var.service_account
3637
}

examples/mig/full/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module "instance_template" {
3232

3333
name_prefix = "${var.hostname}-instance-template"
3434
project_id = var.project_id
35+
region = var.region
3536
machine_type = var.machine_type
3637
tags = var.tags
3738
labels = var.labels

examples/mig/healthcheck/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ module "instance_template" {
5555
version = "~> 12.0"
5656

5757
project_id = var.project_id
58+
region = var.region
5859
subnetwork = google_compute_subnetwork.main.name
5960
service_account = var.service_account
6061
}

examples/mig/simple/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module "instance_template" {
2929
version = "~> 12.0"
3030

3131
project_id = var.project_id
32+
region = var.region
3233
subnetwork = var.subnetwork
3334
service_account = var.service_account
3435
subnetwork_project = var.project_id

examples/mig_with_percent/simple/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ module "preemptible_and_regular_instance_templates" {
3030
source = "terraform-google-modules/vm/google//modules/preemptible_and_regular_instance_templates"
3131
version = "~> 12.0"
3232

33+
project_id = var.project_id
34+
region = var.region
3335
subnetwork = var.subnetwork
3436
service_account = var.service_account
3537
}

0 commit comments

Comments
 (0)