diff --git a/docs/upgrading_to_mig_v13.0.md b/docs/upgrading_to_mig_v13.0.md index f982772c..e62b0a10 100644 --- a/docs/upgrading_to_mig_v13.0.md +++ b/docs/upgrading_to_mig_v13.0.md @@ -1,11 +1,20 @@ -# Upgrading to MIG v13.0 +# Upgrading to 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`. +The v13.0 release of MIG and instance_template is a backwards incompatible release. + +## `modules/mig` and `modules/mig_with_percent` + +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. +## `modules/instance_template` and `modules/preemptible_and_regular_instance_templates` + +* Now the `project_id` and `region` is required input variable. Earlier it was set to `null` by default. + + ## Migration Instructions -### Explicitly provide project_id as input to the MIG module +### Explicitly provide project_id as input to the MIG modules Users would need to provide project_id explicitly while using v13.0 of mig/mig_with_percent. @@ -14,7 +23,7 @@ For mig, ```diff module "mig" { source = "terraform-google-modules/vm/google//modules/mig" - version = "~> 12.0" + version = "~> 13.0" + project_id = var.project_id region = var.region @@ -29,7 +38,7 @@ For mig_with_percent, ```diff module "mig_with_percent" { source = "terraform-google-modules/vm/google//modules/mig_with_percent" - version = "~> 12.0" + version = "~> 13.0" + project_id = var.project_id region = var.region @@ -40,3 +49,43 @@ module "mig_with_percent" { next_version_percent = 50 } ``` + +### Explicitly provide project_id/region as input to the instance_template modules + +For instance_template, + +```diff +module "instance_template" { + source = "terraform-google-modules/vm/google//modules/instance_template" + version = "~> 13.0" + ++ project_id = var.project_id ++ region = var.region + subnetwork = var.subnetwork + stack_type = "IPV4_ONLY" + service_account = var.service_account + name_prefix = "simple" + tags = var.tags + labels = var.labels + access_config = [local.access_config] + enable_nested_virtualization = var.enable_nested_virtualization + threads_per_core = var.threads_per_core +} +``` + +For preemptible_and_regular_instance_templates + +```diff +module "preemptible_and_regular_instance_templates" { + source = "terraform-google-modules/vm/google//modules/preemptible_and_regular_instance_templates" + version = "~> 13.0" + + subnetwork = var.subnetwork ++ project_id = var.project_id ++ region = var.region + service_account = var.service_account + name_prefix = "pvm-and-regular-simple" + tags = var.tags + labels = var.labels +} +``` diff --git a/examples/instance_template/additional_disks/main.tf b/examples/instance_template/additional_disks/main.tf index dd03111c..d57f2fca 100644 --- a/examples/instance_template/additional_disks/main.tf +++ b/examples/instance_template/additional_disks/main.tf @@ -25,6 +25,7 @@ module "instance_template" { version = "~> 12.0" project_id = var.project_id + region = var.region subnetwork = var.subnetwork service_account = var.service_account name_prefix = "additional-disks" diff --git a/examples/instance_template/alias_ip_range/main.tf b/examples/instance_template/alias_ip_range/main.tf index c9cb989c..48a4656a 100644 --- a/examples/instance_template/alias_ip_range/main.tf +++ b/examples/instance_template/alias_ip_range/main.tf @@ -29,6 +29,7 @@ module "instance_template" { version = "~> 12.0" project_id = var.project_id + region = var.region subnetwork = var.subnetwork service_account = var.service_account name_prefix = "alias-ip-range" diff --git a/examples/instance_template/simple/main.tf b/examples/instance_template/simple/main.tf index 69d468cd..1b804abb 100644 --- a/examples/instance_template/simple/main.tf +++ b/examples/instance_template/simple/main.tf @@ -36,6 +36,7 @@ module "instance_template" { version = "~> 12.0" project_id = var.project_id + region = var.region subnetwork = var.subnetwork stack_type = "IPV4_ONLY" service_account = var.service_account diff --git a/examples/mig/autoscaler/main.tf b/examples/mig/autoscaler/main.tf index a5de5599..c3f95e4a 100644 --- a/examples/mig/autoscaler/main.tf +++ b/examples/mig/autoscaler/main.tf @@ -31,6 +31,7 @@ module "instance_template" { version = "~> 12.0" project_id = var.project_id + region = var.region subnetwork = var.subnetwork service_account = var.service_account } diff --git a/examples/mig/healthcheck/main.tf b/examples/mig/healthcheck/main.tf index b14cbf56..a9f2ed07 100644 --- a/examples/mig/healthcheck/main.tf +++ b/examples/mig/healthcheck/main.tf @@ -55,6 +55,7 @@ module "instance_template" { version = "~> 12.0" project_id = var.project_id + region = var.region subnetwork = google_compute_subnetwork.main.name service_account = var.service_account } diff --git a/examples/mig/simple/main.tf b/examples/mig/simple/main.tf index 3eafbfb0..da03a435 100644 --- a/examples/mig/simple/main.tf +++ b/examples/mig/simple/main.tf @@ -29,6 +29,7 @@ module "instance_template" { version = "~> 12.0" project_id = var.project_id + region = var.region subnetwork = var.subnetwork service_account = var.service_account subnetwork_project = var.project_id diff --git a/examples/mig_with_percent/simple/main.tf b/examples/mig_with_percent/simple/main.tf index e54b7f15..2aaa16e1 100644 --- a/examples/mig_with_percent/simple/main.tf +++ b/examples/mig_with_percent/simple/main.tf @@ -30,6 +30,8 @@ module "preemptible_and_regular_instance_templates" { source = "terraform-google-modules/vm/google//modules/preemptible_and_regular_instance_templates" version = "~> 12.0" + project_id = var.project_id + region = var.region subnetwork = var.subnetwork service_account = var.service_account } diff --git a/examples/preemptible_and_regular_instance_templates/simple/main.tf b/examples/preemptible_and_regular_instance_templates/simple/main.tf index 46bced93..4d2f806b 100644 --- a/examples/preemptible_and_regular_instance_templates/simple/main.tf +++ b/examples/preemptible_and_regular_instance_templates/simple/main.tf @@ -26,6 +26,7 @@ module "preemptible_and_regular_instance_templates" { subnetwork = var.subnetwork project_id = var.project_id + region = var.region service_account = var.service_account name_prefix = "pvm-and-regular-simple" tags = var.tags diff --git a/examples/umig/named_ports/main.tf b/examples/umig/named_ports/main.tf index 04674aaf..309b46df 100644 --- a/examples/umig/named_ports/main.tf +++ b/examples/umig/named_ports/main.tf @@ -25,6 +25,7 @@ module "instance_template" { version = "~> 12.0" project_id = var.project_id + region = var.region subnetwork = var.subnetwork service_account = var.service_account } diff --git a/examples/umig/simple/main.tf b/examples/umig/simple/main.tf index ae491cfc..2a5d0d95 100644 --- a/examples/umig/simple/main.tf +++ b/examples/umig/simple/main.tf @@ -25,6 +25,7 @@ module "instance_template" { version = "~> 12.0" project_id = var.project_id + region = var.region subnetwork = var.subnetwork subnetwork_project = var.project_id service_account = var.service_account diff --git a/examples/umig/static_ips/main.tf b/examples/umig/static_ips/main.tf index 7d494c6b..1a5b4cfd 100644 --- a/examples/umig/static_ips/main.tf +++ b/examples/umig/static_ips/main.tf @@ -25,6 +25,7 @@ module "instance_template" { version = "~> 12.0" project_id = var.project_id + region = var.region subnetwork = var.subnetwork subnetwork_project = var.project_id service_account = var.service_account diff --git a/modules/instance_template/README.md b/modules/instance_template/README.md index 0127382c..5d3dd7a9 100644 --- a/modules/instance_template/README.md +++ b/modules/instance_template/README.md @@ -44,8 +44,8 @@ See the [simple](../../examples/instance_template/simple) for a usage example. | nic\_type | Valid values are "VIRTIO\_NET", "GVNIC" or set to null to accept API default behavior. | `string` | `null` | no | | on\_host\_maintenance | Instance availability Policy | `string` | `"MIGRATE"` | no | | preemptible | Allow the instance to be preempted | `bool` | `false` | no | -| project\_id | The GCP project ID | `string` | `null` | no | -| region | Region where the instance template should be created. | `string` | `null` | no | +| project\_id | The GCP project ID | `string` | n/a | yes | +| region | Region where the instance template should be created. | `string` | n/a | yes | | resource\_policies | A list of self\_links of resource policies to attach to the instance. Modifying this list will cause the instance to recreate. Currently a max of 1 resource policy is supported. | `list(string)` | `[]` | no | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account. |
object({| n/a | yes | | shielded\_instance\_config | Not used unless enable\_shielded\_vm is true. Shielded VM configuration for the instance. |
email = string
scopes = optional(set(string), ["cloud-platform"])
})
object({|
enable_secure_boot = bool
enable_vtpm = bool
enable_integrity_monitoring = bool
})
{| no | diff --git a/modules/instance_template/metadata.yaml b/modules/instance_template/metadata.yaml index 4064f403..ba72ce94 100644 --- a/modules/instance_template/metadata.yaml +++ b/modules/instance_template/metadata.yaml @@ -83,9 +83,11 @@ spec: - name: project_id description: The GCP project ID varType: string + required: true - name: region description: Region where the instance template should be created. varType: string + required: true - name: name_prefix description: Name prefix for the instance template varType: string diff --git a/modules/instance_template/variables.tf b/modules/instance_template/variables.tf index a7162fcb..f15468df 100644 --- a/modules/instance_template/variables.tf +++ b/modules/instance_template/variables.tf @@ -17,13 +17,11 @@ variable "project_id" { type = string description = "The GCP project ID" - default = null } variable "region" { type = string description = "Region where the instance template should be created." - default = null } variable "name_prefix" { diff --git a/modules/preemptible_and_regular_instance_templates/README.md b/modules/preemptible_and_regular_instance_templates/README.md index fce29084..344e25cb 100644 --- a/modules/preemptible_and_regular_instance_templates/README.md +++ b/modules/preemptible_and_regular_instance_templates/README.md @@ -24,7 +24,8 @@ See the [simple](../../examples/preemptible_and_regular_instance_templates/simpl | metadata | Metadata, provided as a map | `map(string)` | `{}` | no | | name\_prefix | Name prefix for the instance template | `string` | `"default-it"` | no | | network | The name or self\_link of the network to attach this interface to. Use network attribute for Legacy or Auto subnetted networks and subnetwork for custom subnetted networks. | `string` | `""` | no | -| project\_id | The GCP project ID | `string` | `null` | no | +| project\_id | The GCP project ID | `string` | n/a | yes | +| region | Region where the instance template should be created. | `string` | n/a | yes | | service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account. |
"enable_integrity_monitoring": true,
"enable_secure_boot": true,
"enable_vtpm": true
}
object({| n/a | yes | | source\_image | Source disk image. If neither source\_image nor source\_image\_family is specified, defaults to the latest public Rocky Linux 9 optimized for GCP image. | `string` | `""` | no | | source\_image\_family | Source image family. If neither source\_image nor source\_image\_family is specified, defaults to the latest public Rocky Linux 9 optimized for GCP image. | `string` | `""` | no | diff --git a/modules/preemptible_and_regular_instance_templates/main.tf b/modules/preemptible_and_regular_instance_templates/main.tf index 523ab69b..da2a91bd 100644 --- a/modules/preemptible_and_regular_instance_templates/main.tf +++ b/modules/preemptible_and_regular_instance_templates/main.tf @@ -22,6 +22,7 @@ module "preemptible" { source = "../../modules/instance_template" name_prefix = "${var.name_prefix}-preemptible" project_id = var.project_id + region = var.region machine_type = var.machine_type labels = var.labels metadata = var.metadata @@ -48,6 +49,7 @@ module "regular" { source = "../../modules/instance_template" name_prefix = "${var.name_prefix}-regular" project_id = var.project_id + region = var.region machine_type = var.machine_type labels = var.labels metadata = var.metadata diff --git a/modules/preemptible_and_regular_instance_templates/metadata.yaml b/modules/preemptible_and_regular_instance_templates/metadata.yaml index bee9b70b..9cd8a37c 100644 --- a/modules/preemptible_and_regular_instance_templates/metadata.yaml +++ b/modules/preemptible_and_regular_instance_templates/metadata.yaml @@ -83,6 +83,11 @@ spec: - name: project_id description: The GCP project ID varType: string + required: true + - name: region + description: Region where the instance template should be created. + varType: string + required: true - name: name_prefix description: Name prefix for the instance template varType: string diff --git a/modules/preemptible_and_regular_instance_templates/variables.tf b/modules/preemptible_and_regular_instance_templates/variables.tf index a6973954..a6bb685d 100644 --- a/modules/preemptible_and_regular_instance_templates/variables.tf +++ b/modules/preemptible_and_regular_instance_templates/variables.tf @@ -17,7 +17,11 @@ variable "project_id" { type = string description = "The GCP project ID" - default = null +} + +variable "region" { + type = string + description = "Region where the instance template should be created." } variable "name_prefix" {
email = string
scopes = set(string)
})