diff --git a/autogen/outputs.tf.tmpl b/autogen/outputs.tf.tmpl index 5abb642e..f43d0a9a 100644 --- a/autogen/outputs.tf.tmpl +++ b/autogen/outputs.tf.tmpl @@ -40,7 +40,7 @@ output "health_check_self_links" { output "apphub_workload_uri" { value = { workload_uri = "//compute.googleapis.com/projects${element(split("/projects", google_compute_region_instance_group_manager.mig.instance_group), 1)}" - workload_id = substr(join("-", [tostring(google_compute_region_instance_group_manager.mig.name), md5(tostring(google_compute_region_instance_group_manager.mig.self_link))]), 0, 63) + workload_id = substr(join("-", [tostring(google_compute_region_instance_group_manager.mig.name), md5(join("-", [var.region, var.project_id]))]), 0, 63) } description = "Workload URI in CAIS style to be used by Apphub." } diff --git a/autogen/variables.tf.tmpl b/autogen/variables.tf.tmpl index 76e395c1..0fb09e83 100644 --- a/autogen/variables.tf.tmpl +++ b/autogen/variables.tf.tmpl @@ -19,7 +19,6 @@ variable "project_id" { type = string description = "The Google Cloud project ID" - default = null } variable "region" { diff --git a/docs/upgrading_to_mig_v13.0.md b/docs/upgrading_to_mig_v13.0.md new file mode 100644 index 00000000..f982772c --- /dev/null +++ b/docs/upgrading_to_mig_v13.0.md @@ -0,0 +1,42 @@ +# Upgrading to MIG v13.0 + +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`. +Users might be bypassing this by setting project at provider level and not providing `project_id` for mig module. + +## Migration Instructions + +### Explicitly provide project_id as input to the MIG module + +Users would need to provide project_id explicitly while using v13.0 of mig/mig_with_percent. + +For mig, + +```diff +module "mig" { + source = "terraform-google-modules/vm/google//modules/mig" + version = "~> 12.0" + ++ project_id = var.project_id + region = var.region + target_size = var.target_size + hostname = "mig-simple" + instance_template = module.instance_template.self_link +} +``` + +For mig_with_percent, + +```diff +module "mig_with_percent" { + source = "terraform-google-modules/vm/google//modules/mig_with_percent" + version = "~> 12.0" + ++ project_id = var.project_id + region = var.region + target_size = 4 + hostname = "mig-with-percent-simple" + instance_template_initial_version = module.preemptible_and_regular_instance_templates.regular_self_link + instance_template_next_version = module.preemptible_and_regular_instance_templates.preemptible_self_link + next_version_percent = 50 +} +``` diff --git a/examples/mig_with_percent/simple/main.tf b/examples/mig_with_percent/simple/main.tf index 9ac59196..e54b7f15 100644 --- a/examples/mig_with_percent/simple/main.tf +++ b/examples/mig_with_percent/simple/main.tf @@ -38,6 +38,7 @@ module "mig_with_percent" { source = "terraform-google-modules/vm/google//modules/mig_with_percent" version = "~> 12.0" + project_id = var.project_id region = var.region target_size = 4 hostname = "mig-with-percent-simple" diff --git a/modules/mig/README.md b/modules/mig/README.md index 62be74c7..9d54b711 100644 --- a/modules/mig/README.md +++ b/modules/mig/README.md @@ -38,7 +38,7 @@ The current version is 2.X. The following guides are available to assist with up | mig\_timeouts | Times for creation, deleting and updating the MIG resources. Can be helpful when using wait\_for\_instances to allow a longer VM startup time. |
object({
create = string
update = string
delete = string
}) | {
"create": "5m",
"delete": "15m",
"update": "5m"
} | no |
| min\_replicas | The minimum number of replicas that the autoscaler can scale down to. This cannot be less than 0. | `number` | `2` | no |
| named\_ports | Named name and named port. https://cloud.google.com/load-balancing/docs/backend-service#named_ports | list(object({
name = string
port = number
})) | `[]` | no |
-| project\_id | The Google Cloud project ID | `string` | `null` | no |
+| project\_id | The Google Cloud project ID | `string` | n/a | yes |
| region | The Google Cloud region where the managed instance group resides. | `string` | n/a | yes |
| scaling\_schedules | Autoscaling, scaling schedule block. https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_autoscaler#scaling_schedules | list(object({
disabled = bool
duration_sec = number
min_required_replicas = number
name = string
schedule = string
time_zone = string
})) | `[]` | no |
| stateful\_disks | Disks created on the instances that will be preserved on instance delete. https://cloud.google.com/compute/docs/instance-groups/configuring-stateful-disks-in-migs | list(object({
device_name = string
delete_rule = string
})) | `[]` | no |
diff --git a/modules/mig/metadata.yaml b/modules/mig/metadata.yaml
index 72505e25..7e666612 100644
--- a/modules/mig/metadata.yaml
+++ b/modules/mig/metadata.yaml
@@ -83,6 +83,7 @@ spec:
- name: project_id
description: The Google Cloud project ID
varType: string
+ required: true
- name: region
description: The Google Cloud region where the managed instance group resides.
varType: string
diff --git a/modules/mig/outputs.tf b/modules/mig/outputs.tf
index d5aecf35..28570b66 100644
--- a/modules/mig/outputs.tf
+++ b/modules/mig/outputs.tf
@@ -39,7 +39,7 @@ output "health_check_self_links" {
output "apphub_workload_uri" {
value = {
workload_uri = "//compute.googleapis.com/projects${element(split("/projects", google_compute_region_instance_group_manager.mig.instance_group), 1)}"
- workload_id = substr(join("-", [tostring(google_compute_region_instance_group_manager.mig.name), md5(tostring(google_compute_region_instance_group_manager.mig.self_link))]), 0, 63)
+ workload_id = substr(join("-", [tostring(google_compute_region_instance_group_manager.mig.name), md5(join("-", [var.region, var.project_id]))]), 0, 63)
}
description = "Workload URI in CAIS style to be used by Apphub."
}
diff --git a/modules/mig/variables.tf b/modules/mig/variables.tf
index 2c093049..3ce60742 100644
--- a/modules/mig/variables.tf
+++ b/modules/mig/variables.tf
@@ -19,7 +19,6 @@
variable "project_id" {
type = string
description = "The Google Cloud project ID"
- default = null
}
variable "region" {
diff --git a/modules/mig_with_percent/README.md b/modules/mig_with_percent/README.md
index af5c24a0..9660c228 100644
--- a/modules/mig_with_percent/README.md
+++ b/modules/mig_with_percent/README.md
@@ -39,7 +39,7 @@ The current version is 2.X. The following guides are available to assist with up
| min\_replicas | The minimum number of replicas that the autoscaler can scale down to. This cannot be less than 0. | `number` | `2` | no |
| named\_ports | Named name and named port. https://cloud.google.com/load-balancing/docs/backend-service#named_ports | list(object({
name = string
port = number
})) | `[]` | no |
| next\_version\_percent | Percentage of instances defined in the second version | `number` | n/a | yes |
-| project\_id | The Google Cloud project ID | `string` | `null` | no |
+| project\_id | The Google Cloud project ID | `string` | n/a | yes |
| region | The Google Cloud region where the managed instance group resides. | `string` | n/a | yes |
| scaling\_schedules | Autoscaling, scaling schedule block. https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_autoscaler#scaling_schedules | list(object({
disabled = bool
duration_sec = number
min_required_replicas = number
name = string
schedule = string
time_zone = string
})) | `[]` | no |
| stateful\_disks | Disks created on the instances that will be preserved on instance delete. https://cloud.google.com/compute/docs/instance-groups/configuring-stateful-disks-in-migs | list(object({
device_name = string
delete_rule = string
})) | `[]` | no |
diff --git a/modules/mig_with_percent/metadata.yaml b/modules/mig_with_percent/metadata.yaml
index d461c93d..a1091159 100644
--- a/modules/mig_with_percent/metadata.yaml
+++ b/modules/mig_with_percent/metadata.yaml
@@ -83,6 +83,7 @@ spec:
- name: project_id
description: The Google Cloud project ID
varType: string
+ required: true
- name: region
description: The Google Cloud region where the managed instance group resides.
varType: string
diff --git a/modules/mig_with_percent/variables.tf b/modules/mig_with_percent/variables.tf
index 60a9d38a..7ca5af4b 100644
--- a/modules/mig_with_percent/variables.tf
+++ b/modules/mig_with_percent/variables.tf
@@ -19,7 +19,6 @@
variable "project_id" {
type = string
description = "The Google Cloud project ID"
- default = null
}
variable "region" {