diff --git a/examples/umig/named_ports/main.tf b/examples/umig/named_ports/main.tf index bfb40696..44e7a7fa 100644 --- a/examples/umig/named_ports/main.tf +++ b/examples/umig/named_ports/main.tf @@ -24,6 +24,7 @@ module "instance_template" { source = "terraform-google-modules/vm/google//modules/instance_template" version = "~> 10.0" + project_id = var.project_id subnetwork = var.subnetwork service_account = var.service_account } diff --git a/examples/umig/simple/main.tf b/examples/umig/simple/main.tf index 5df2964e..34b644f6 100644 --- a/examples/umig/simple/main.tf +++ b/examples/umig/simple/main.tf @@ -24,6 +24,7 @@ module "instance_template" { source = "terraform-google-modules/vm/google//modules/instance_template" version = "~> 10.0" + project_id = var.project_id subnetwork = var.subnetwork service_account = var.service_account } diff --git a/examples/umig/static_ips/main.tf b/examples/umig/static_ips/main.tf index 7fc8af6d..f4362151 100644 --- a/examples/umig/static_ips/main.tf +++ b/examples/umig/static_ips/main.tf @@ -24,6 +24,7 @@ module "instance_template" { source = "terraform-google-modules/vm/google//modules/instance_template" version = "~> 10.0" + project_id = var.project_id subnetwork = var.subnetwork service_account = var.service_account } diff --git a/modules/instance_template/README.md b/modules/instance_template/README.md index 85ed1066..2b39fee6 100644 --- a/modules/instance_template/README.md +++ b/modules/instance_template/README.md @@ -31,6 +31,7 @@ See the [simple](../../examples/instance_template/simple) for a usage example. | ipv6\_access\_config | IPv6 access configurations. Currently a max of 1 IPv6 access configuration is supported. If not specified, the instance will have no external IPv6 Internet access. |
list(object({
network_tier = string
}))
| `[]` | no | | labels | Labels, provided as a map | `map(string)` | `{}` | no | | machine\_type | Machine type to create, e.g. n1-standard-1 | `string` | `"n1-standard-1"` | no | +| maintenance\_interval | Specifies the frequency of planned maintenance events | `string` | `null` | no | | metadata | Metadata, provided as a map | `map(string)` | `{}` | no | | min\_cpu\_platform | Specifies a minimum CPU platform. Applicable values are the friendly names of CPU platforms, such as Intel Haswell or Intel Skylake. See the complete list: https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform | `string` | `null` | no | | name\_prefix | Name prefix for the instance template | `string` | `"default-instance-template"` | no | diff --git a/modules/instance_template/main.tf b/modules/instance_template/main.tf index c2483352..573a0e22 100644 --- a/modules/instance_template/main.tf +++ b/modules/instance_template/main.tf @@ -63,6 +63,7 @@ locals { # Instance Template #################### resource "google_compute_instance_template" "tpl" { + provider = google-beta name_prefix = "${var.name_prefix}-" project = var.project_id machine_type = var.machine_type @@ -175,11 +176,12 @@ resource "google_compute_instance_template" "tpl" { } scheduling { - preemptible = local.preemptible automatic_restart = local.automatic_restart + instance_termination_action = var.spot ? var.spot_instance_termination_action : null + maintenance_interval = var.maintenance_interval on_host_maintenance = local.on_host_maintenance + preemptible = local.preemptible provisioning_model = var.spot ? "SPOT" : null - instance_termination_action = var.spot ? var.spot_instance_termination_action : null } advanced_machine_features { diff --git a/modules/instance_template/metadata.yaml b/modules/instance_template/metadata.yaml index b90fcce5..5ce66ed2 100644 --- a/modules/instance_template/metadata.yaml +++ b/modules/instance_template/metadata.yaml @@ -194,6 +194,10 @@ spec: description: Machine type to create, e.g. n1-standard-1 varType: string defaultValue: n1-standard-1 + - name: maintenance_interval + description: Specifies the frequency of planned maintenance events + varType: string + defaultValue: null - name: metadata description: Metadata, provided as a map varType: map(string) diff --git a/modules/instance_template/variables.tf b/modules/instance_template/variables.tf index 862bee68..2efa8608 100644 --- a/modules/instance_template/variables.tf +++ b/modules/instance_template/variables.tf @@ -74,6 +74,16 @@ variable "automatic_restart" { default = true } +variable "maintenance_interval" { + type = string + description = "Specifies the frequency of planned maintenance events" + default = null + validation { + condition = var.maintenance_interval == null || var.maintenance_interval == "PERIODIC" + error_message = "var.maintenance_interval must be set to null or \"PERIODIC\"" + } +} + variable "on_host_maintenance" { type = string description = "Instance availability Policy" diff --git a/modules/instance_template/versions.tf b/modules/instance_template/versions.tf index 46563308..162ce96b 100644 --- a/modules/instance_template/versions.tf +++ b/modules/instance_template/versions.tf @@ -17,9 +17,9 @@ terraform { required_version = ">=0.13.0" required_providers { - google = { - source = "hashicorp/google" - version = ">= 4.67, < 6" + google-beta = { + source = "hashicorp/google-beta" + version = ">= 5.5, < 6" } } provider_meta "google" { diff --git a/test/fixtures/instance_template/additional_disks/main.tf b/test/fixtures/instance_template/additional_disks/main.tf index 9598d6ab..335c6bf1 100644 --- a/test/fixtures/instance_template/additional_disks/main.tf +++ b/test/fixtures/instance_template/additional_disks/main.tf @@ -17,7 +17,7 @@ module "instance_template_additional_disks" { source = "../../../../examples/instance_template/additional_disks" project_id = var.project_id - subnetwork = google_compute_subnetwork.main.name + subnetwork = google_compute_subnetwork.main.self_link service_account = var.service_account } diff --git a/test/fixtures/instance_template/alias_ip_range/main.tf b/test/fixtures/instance_template/alias_ip_range/main.tf index 41e1b133..83e98dd9 100644 --- a/test/fixtures/instance_template/alias_ip_range/main.tf +++ b/test/fixtures/instance_template/alias_ip_range/main.tf @@ -17,6 +17,6 @@ module "instance_template_alias_ip_range" { source = "../../../../examples/instance_template/alias_ip_range" project_id = var.project_id - subnetwork = google_compute_subnetwork.main.name + subnetwork = google_compute_subnetwork.main.self_link service_account = var.service_account } diff --git a/test/fixtures/instance_template/simple/main.tf b/test/fixtures/instance_template/simple/main.tf index a6f13c9d..395e8e6d 100644 --- a/test/fixtures/instance_template/simple/main.tf +++ b/test/fixtures/instance_template/simple/main.tf @@ -17,7 +17,7 @@ module "instance_template_simple" { source = "../../../../examples/instance_template/simple" project_id = var.project_id - subnetwork = google_compute_subnetwork.main.name + subnetwork = google_compute_subnetwork.main.self_link service_account = var.service_account tags = ["foo", "bar"] diff --git a/test/fixtures/mig/autoscaler/main.tf b/test/fixtures/mig/autoscaler/main.tf index 6df78ba9..aeeedad6 100644 --- a/test/fixtures/mig/autoscaler/main.tf +++ b/test/fixtures/mig/autoscaler/main.tf @@ -17,7 +17,7 @@ module "mig_autoscaler" { source = "../../../../examples/mig/autoscaler" project_id = var.project_id - subnetwork = google_compute_subnetwork.main.name + subnetwork = google_compute_subnetwork.main.self_link service_account = var.service_account autoscaling_enabled = "true" min_replicas = 4 diff --git a/test/fixtures/mig/simple/main.tf b/test/fixtures/mig/simple/main.tf index d832f40e..5a94614d 100644 --- a/test/fixtures/mig/simple/main.tf +++ b/test/fixtures/mig/simple/main.tf @@ -17,7 +17,7 @@ module "mig_simple" { source = "../../../../examples/mig/simple" project_id = var.project_id - subnetwork = google_compute_subnetwork.main.name + subnetwork = google_compute_subnetwork.main.self_link target_size = 4 service_account = var.service_account } diff --git a/test/fixtures/mig_stateful/main.tf b/test/fixtures/mig_stateful/main.tf index 983f12d6..d7eb7fca 100644 --- a/test/fixtures/mig_stateful/main.tf +++ b/test/fixtures/mig_stateful/main.tf @@ -18,7 +18,7 @@ module "mig_stateful" { source = "../../../examples/mig_stateful" project_id = var.project_id region = "us-central1" - subnetwork = google_compute_subnetwork.main.name + subnetwork = google_compute_subnetwork.main.self_link target_size = 3 service_account = var.service_account } diff --git a/test/fixtures/mig_with_percent/simple/main.tf b/test/fixtures/mig_with_percent/simple/main.tf index c40b1119..10217848 100644 --- a/test/fixtures/mig_with_percent/simple/main.tf +++ b/test/fixtures/mig_with_percent/simple/main.tf @@ -17,6 +17,6 @@ module "mig_with_percent_simple" { source = "../../../../examples/mig_with_percent/simple" project_id = var.project_id - subnetwork = google_compute_subnetwork.main.name + subnetwork = google_compute_subnetwork.main.self_link service_account = var.service_account } diff --git a/test/fixtures/preemptible_and_regular_instance_templates/simple/main.tf b/test/fixtures/preemptible_and_regular_instance_templates/simple/main.tf index bc7389d0..03ee8cc4 100644 --- a/test/fixtures/preemptible_and_regular_instance_templates/simple/main.tf +++ b/test/fixtures/preemptible_and_regular_instance_templates/simple/main.tf @@ -17,7 +17,7 @@ module "preemptible_and_regular_instance_templates" { source = "../../../../examples/preemptible_and_regular_instance_templates/simple" project_id = var.project_id - subnetwork = google_compute_subnetwork.main.name + subnetwork = google_compute_subnetwork.main.self_link service_account = var.service_account tags = ["foo", "bar"] diff --git a/test/fixtures/umig/named_ports/main.tf b/test/fixtures/umig/named_ports/main.tf index e86b2f34..5543a9af 100644 --- a/test/fixtures/umig/named_ports/main.tf +++ b/test/fixtures/umig/named_ports/main.tf @@ -18,7 +18,7 @@ module "umig_named_ports" { source = "../../../../examples/umig/named_ports" project_id = var.project_id region = "us-central1" - subnetwork = google_compute_subnetwork.main.name + subnetwork = google_compute_subnetwork.main.self_link num_instances = 4 service_account = var.service_account diff --git a/test/fixtures/umig/simple/main.tf b/test/fixtures/umig/simple/main.tf index 0296b3b2..2d3c8808 100644 --- a/test/fixtures/umig/simple/main.tf +++ b/test/fixtures/umig/simple/main.tf @@ -18,7 +18,7 @@ module "umig_simple" { source = "../../../../examples/umig/simple" project_id = var.project_id region = "us-central1" - subnetwork = google_compute_subnetwork.main.name + subnetwork = google_compute_subnetwork.main.self_link num_instances = 4 service_account = var.service_account } diff --git a/test/fixtures/umig/static_ips/main.tf b/test/fixtures/umig/static_ips/main.tf index 94f73296..04b4f22b 100644 --- a/test/fixtures/umig/static_ips/main.tf +++ b/test/fixtures/umig/static_ips/main.tf @@ -18,7 +18,7 @@ module "umig_static_ips" { source = "../../../../examples/umig/static_ips" project_id = var.project_id region = "us-central1" - subnetwork = google_compute_subnetwork.main.name + subnetwork = google_compute_subnetwork.main.self_link static_ips = [ "10.128.0.10",