Skip to content

Commit c7b47bc

Browse files
tpdownesapeabodyg-awmalik
authored
feat(TPG>=5.5)!: support setting maintenance_interval in instance_template (#357)
Co-authored-by: Andrew Peabody <[email protected]> Co-authored-by: Awais Malik <[email protected]>
1 parent 5587688 commit c7b47bc

File tree

19 files changed

+36
-16
lines changed

19 files changed

+36
-16
lines changed

examples/umig/named_ports/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module "instance_template" {
2424
source = "terraform-google-modules/vm/google//modules/instance_template"
2525
version = "~> 10.0"
2626

27+
project_id = var.project_id
2728
subnetwork = var.subnetwork
2829
service_account = var.service_account
2930
}

examples/umig/simple/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module "instance_template" {
2424
source = "terraform-google-modules/vm/google//modules/instance_template"
2525
version = "~> 10.0"
2626

27+
project_id = var.project_id
2728
subnetwork = var.subnetwork
2829
service_account = var.service_account
2930
}

examples/umig/static_ips/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module "instance_template" {
2424
source = "terraform-google-modules/vm/google//modules/instance_template"
2525
version = "~> 10.0"
2626

27+
project_id = var.project_id
2728
subnetwork = var.subnetwork
2829
service_account = var.service_account
2930
}

modules/instance_template/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ See the [simple](../../examples/instance_template/simple) for a usage example.
3131
| 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. | <pre>list(object({<br> network_tier = string<br> }))</pre> | `[]` | no |
3232
| labels | Labels, provided as a map | `map(string)` | `{}` | no |
3333
| machine\_type | Machine type to create, e.g. n1-standard-1 | `string` | `"n1-standard-1"` | no |
34+
| maintenance\_interval | Specifies the frequency of planned maintenance events | `string` | `null` | no |
3435
| metadata | Metadata, provided as a map | `map(string)` | `{}` | no |
3536
| 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 |
3637
| name\_prefix | Name prefix for the instance template | `string` | `"default-instance-template"` | no |

modules/instance_template/main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ locals {
6363
# Instance Template
6464
####################
6565
resource "google_compute_instance_template" "tpl" {
66+
provider = google-beta
6667
name_prefix = "${var.name_prefix}-"
6768
project = var.project_id
6869
machine_type = var.machine_type
@@ -175,11 +176,12 @@ resource "google_compute_instance_template" "tpl" {
175176
}
176177

177178
scheduling {
178-
preemptible = local.preemptible
179179
automatic_restart = local.automatic_restart
180+
instance_termination_action = var.spot ? var.spot_instance_termination_action : null
181+
maintenance_interval = var.maintenance_interval
180182
on_host_maintenance = local.on_host_maintenance
183+
preemptible = local.preemptible
181184
provisioning_model = var.spot ? "SPOT" : null
182-
instance_termination_action = var.spot ? var.spot_instance_termination_action : null
183185
}
184186

185187
advanced_machine_features {

modules/instance_template/metadata.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ spec:
194194
description: Machine type to create, e.g. n1-standard-1
195195
varType: string
196196
defaultValue: n1-standard-1
197+
- name: maintenance_interval
198+
description: Specifies the frequency of planned maintenance events
199+
varType: string
200+
defaultValue: null
197201
- name: metadata
198202
description: Metadata, provided as a map
199203
varType: map(string)

modules/instance_template/variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ variable "automatic_restart" {
7474
default = true
7575
}
7676

77+
variable "maintenance_interval" {
78+
type = string
79+
description = "Specifies the frequency of planned maintenance events"
80+
default = null
81+
validation {
82+
condition = var.maintenance_interval == null || var.maintenance_interval == "PERIODIC"
83+
error_message = "var.maintenance_interval must be set to null or \"PERIODIC\""
84+
}
85+
}
86+
7787
variable "on_host_maintenance" {
7888
type = string
7989
description = "Instance availability Policy"

modules/instance_template/versions.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
terraform {
1818
required_version = ">=0.13.0"
1919
required_providers {
20-
google = {
21-
source = "hashicorp/google"
22-
version = ">= 4.67, < 6"
20+
google-beta = {
21+
source = "hashicorp/google-beta"
22+
version = ">= 5.5, < 6"
2323
}
2424
}
2525
provider_meta "google" {

test/fixtures/instance_template/additional_disks/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
module "instance_template_additional_disks" {
1818
source = "../../../../examples/instance_template/additional_disks"
1919
project_id = var.project_id
20-
subnetwork = google_compute_subnetwork.main.name
20+
subnetwork = google_compute_subnetwork.main.self_link
2121
service_account = var.service_account
2222
}
2323

test/fixtures/instance_template/alias_ip_range/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
module "instance_template_alias_ip_range" {
1818
source = "../../../../examples/instance_template/alias_ip_range"
1919
project_id = var.project_id
20-
subnetwork = google_compute_subnetwork.main.name
20+
subnetwork = google_compute_subnetwork.main.self_link
2121
service_account = var.service_account
2222
}

0 commit comments

Comments
 (0)