diff --git a/mmv1/third_party/terraform/resources/resource_compute_instance.go.erb b/mmv1/third_party/terraform/resources/resource_compute_instance.go.erb
index cef546dd6878..f8569666c13d 100644
--- a/mmv1/third_party/terraform/resources/resource_compute_instance.go.erb
+++ b/mmv1/third_party/terraform/resources/resource_compute_instance.go.erb
@@ -54,6 +54,7 @@ var (
"scheduling.0.instance_termination_action",
<% unless version == 'ga' -%>
"scheduling.0.max_run_duration",
+ "scheduling.0.maintenance_interval",
<% end -%>
}
@@ -675,6 +676,12 @@ be from 0 to 999,999,999 inclusive.`,
},
},
},
+ "maintenance_interval": {
+ Type: schema.TypeString,
+ Optional: true,
+ AtLeastOneOf: schedulingKeys,
+ Description: `Specifies the frequency of planned maintenance events. The accepted values are: PERIODIC`,
+ },
<% end -%>
},
diff --git a/mmv1/third_party/terraform/resources/resource_compute_instance_template.go.erb b/mmv1/third_party/terraform/resources/resource_compute_instance_template.go.erb
index 65713c25b889..20808d509f7f 100644
--- a/mmv1/third_party/terraform/resources/resource_compute_instance_template.go.erb
+++ b/mmv1/third_party/terraform/resources/resource_compute_instance_template.go.erb
@@ -33,6 +33,7 @@ var (
"scheduling.0.instance_termination_action",
<% unless version == 'ga' -%>
"scheduling.0.max_run_duration",
+ "scheduling.0.maintenance_interval",
<% end -%>
}
@@ -652,6 +653,11 @@ be from 0 to 999,999,999 inclusive.`,
},
},
},
+ "maintenance_interval" : {
+ Type: schema.TypeString,
+ Optional: true,
+ Description: `Specifies the frequency of planned maintenance events. The accepted values are: PERIODIC`,
+ },
<% end -%>
},
},
diff --git a/mmv1/third_party/terraform/tests/resource_compute_instance_template_test.go.erb b/mmv1/third_party/terraform/tests/resource_compute_instance_template_test.go.erb
index 916c35c7b8e7..3789cb59a538 100644
--- a/mmv1/third_party/terraform/tests/resource_compute_instance_template_test.go.erb
+++ b/mmv1/third_party/terraform/tests/resource_compute_instance_template_test.go.erb
@@ -298,6 +298,43 @@ func TestAccComputeInstanceTemplate_preemptible(t *testing.T) {
})
}
+<% unless version == "ga" -%>
+func TestAccComputeInstanceTemplate_maintenance_interval(t *testing.T) {
+ t.Parallel()
+
+ var instanceTemplate compute.InstanceTemplate
+
+ VcrTest(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: TestAccProviders,
+ CheckDestroy: testAccCheckComputeInstanceTemplateDestroyProducer(t),
+ Steps: []resource.TestStep{
+ {
+ Config: testAccComputeInstanceTemplate_maintenance_interval(RandString(t, 10)),
+ Check: resource.ComposeTestCheckFunc(
+ testAccCheckComputeInstanceTemplateExists(
+ t, "google_compute_instance_template.foobar", &instanceTemplate),
+ testAccCheckComputeInstanceTemplateMaintenanceInterval(&instanceTemplate, "PERIODIC"),
+ ),
+ },
+ {
+ ResourceName: "google_compute_instance_template.foobar",
+ ImportState: true,
+ ImportStateVerify: true,
+ },
+ {
+ Config: testAccComputeInstanceTemplate_basic(RandString(t, 10)),
+ Check: resource.ComposeTestCheckFunc(
+ testAccCheckComputeInstanceTemplateExists(
+ t, "google_compute_instance_template.foobar", &instanceTemplate),
+ testAccCheckComputeInstanceTemplateMaintenanceInterval(&instanceTemplate, ""),
+ ),
+ },
+ },
+ })
+}
+<% end -%>
+
func TestAccComputeInstanceTemplate_IP(t *testing.T) {
t.Parallel()
@@ -1407,6 +1444,17 @@ func testAccCheckComputeInstanceTemplatePreemptible(instanceTemplate *compute.In
}
}
+<% unless version == "ga" -%>
+func testAccCheckComputeInstanceTemplateMaintenanceInterval(instanceTemplate *compute.InstanceTemplate, maintenance_interval string) resource.TestCheckFunc {
+ return func(s *terraform.State) error {
+ if instanceTemplate.Properties.Scheduling.MaintenanceInterval != maintenance_interval {
+ return fmt.Errorf("Expected maintenance interval value %v, got %v", maintenance_interval, instanceTemplate.Properties.Scheduling.MaintenanceInterval)
+ }
+ return nil
+ }
+}
+<% end -%>
+
func testAccCheckComputeInstanceTemplateProvisioningModel(instanceTemplate *compute.InstanceTemplate, provisioning_model string) resource.TestCheckFunc {
return func(s *terraform.State) error {
if instanceTemplate.Properties.Scheduling.ProvisioningModel != provisioning_model {
@@ -1793,6 +1841,52 @@ resource "google_compute_instance_template" "foobar" {
`, suffix)
}
+<% unless version == 'ga' -%>
+func testAccComputeInstanceTemplate_maintenance_interval(suffix string) string {
+ return fmt.Sprintf(`
+data "google_compute_image" "my_image" {
+ family = "debian-11"
+ project = "debian-cloud"
+}
+
+resource "google_compute_instance_template" "foobar" {
+ name = "tf-test-instance-template-%s"
+ machine_type = "e2-medium"
+ can_ip_forward = false
+ tags = ["foo", "bar"]
+
+ disk {
+ source_image = data.google_compute_image.my_image.self_link
+ auto_delete = true
+ boot = true
+ }
+
+ network_interface {
+ network = "default"
+ }
+
+ scheduling {
+ preemptible = false
+ automatic_restart = true
+ maintenance_interval = "PERIODIC"
+ }
+
+ metadata = {
+ foo = "bar"
+ }
+
+ service_account {
+ scopes = ["userinfo-email", "compute-ro", "storage-ro"]
+ }
+
+ labels = {
+ my_label = "foobar"
+ }
+}
+`, suffix)
+}
+<% end -%>
+
func testAccComputeInstanceTemplate_ip(suffix string) string {
return fmt.Sprintf(`
resource "google_compute_address" "foo" {
diff --git a/mmv1/third_party/terraform/utils/compute_instance_helpers.go.erb b/mmv1/third_party/terraform/utils/compute_instance_helpers.go.erb
index 02488301ef35..d47ac9c953c4 100644
--- a/mmv1/third_party/terraform/utils/compute_instance_helpers.go.erb
+++ b/mmv1/third_party/terraform/utils/compute_instance_helpers.go.erb
@@ -142,6 +142,9 @@ func expandScheduling(v interface{}) (*compute.Scheduling, error) {
scheduling.MaxRunDuration = transformedMaxRunDuration
scheduling.ForceSendFields = append(scheduling.ForceSendFields, "MaxRunDuration")
}
+ if v, ok := original["maintenance_interval"]; ok {
+ scheduling.MaintenanceInterval = v.(string)
+ }
<% end -%>
return scheduling, nil
}
@@ -200,6 +203,9 @@ func flattenScheduling(resp *compute.Scheduling) []map[string]interface{} {
if resp.MaxRunDuration != nil {
schedulingMap["max_run_duration"] = flattenComputeMaxRunDuration(resp.MaxRunDuration)
}
+ if resp.MaintenanceInterval != "" {
+ schedulingMap["maintenance_interval"] = resp.MaintenanceInterval
+ }
<% end -%>
nodeAffinities := schema.NewSet(schema.HashResource(instanceSchedulingNodeAffinitiesElemSchema()), nil)
diff --git a/mmv1/third_party/terraform/website/docs/r/compute_instance.html.markdown b/mmv1/third_party/terraform/website/docs/r/compute_instance.html.markdown
index 5d1f94b9dec1..32928b640697 100644
--- a/mmv1/third_party/terraform/website/docs/r/compute_instance.html.markdown
+++ b/mmv1/third_party/terraform/website/docs/r/compute_instance.html.markdown
@@ -385,7 +385,6 @@ specified, then this instance will have no external IPv6 Internet access. Struct
* `instance_termination_action` - (Optional) Describe the type of termination action for VM. Can be `STOP` or `DELETE`. Read more on [here](https://cloud.google.com/compute/docs/instances/create-use-spot)
* `max_run_duration` - (Optional) [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html) The duration of the instance. Instance will run and be terminated after then, the termination action could be defined in `instance_termination_action`. Only support `DELETE` `instance_termination_action` at this point. Structure is [documented below](#nested_max_run_duration).
-
The `max_run_duration` block supports:
* `nanos` - (Optional) Span of time that's a fraction of a second at nanosecond
@@ -397,6 +396,7 @@ specified, then this instance will have no external IPv6 Internet access. Struct
315,576,000,000 inclusive. Note: these bounds are computed from: 60
sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years.
+* `maintenance_interval` - (Optional) [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html) Specifies the frequency of planned maintenance events. The accepted values are: `PERIODIC`.
The `guest_accelerator` block supports:
* `type` (Required) - The accelerator type resource to expose to this instance. E.g. `nvidia-tesla-k80`.
diff --git a/mmv1/third_party/terraform/website/docs/r/compute_instance_template.html.markdown b/mmv1/third_party/terraform/website/docs/r/compute_instance_template.html.markdown
index 3ecf36b52992..7ab6ed9a5da8 100644
--- a/mmv1/third_party/terraform/website/docs/r/compute_instance_template.html.markdown
+++ b/mmv1/third_party/terraform/website/docs/r/compute_instance_template.html.markdown
@@ -565,19 +565,18 @@ specified, then this instance will have no external IPv6 Internet access. Struct
* `instance_termination_action` - (Optional) Describe the type of termination action for `SPOT` VM. Can be `STOP` or `DELETE`. Read more on [here](https://cloud.google.com/compute/docs/instances/create-use-spot)
* `max_run_duration` - (Optional) [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html) The duration of the instance. Instance will run and be terminated after then, the termination action could be defined in `instance_termination_action`. Only support `DELETE` `instance_termination_action` at this point. Structure is [documented below](#nested_max_run_duration).
-
The `max_run_duration` block supports:
* `nanos` - (Optional) Span of time that's a fraction of a second at nanosecond
- resolution. Durations less than one second are represented with a 0
- `seconds` field and a positive `nanos` field. Must be from 0 to
- 999,999,999 inclusive.
+ resolution. Durations less than one second are represented with a 0
+ `seconds` field and a positive `nanos` field. Must be from 0 to
+ 999,999,999 inclusive.
* `seconds` - (Required) Span of time at a resolution of a second. Must be from 0 to
315,576,000,000 inclusive. Note: these bounds are computed from: 60
sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years.
-
+* `maintenance_interval` - (Optional) [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html) Specifies the frequency of planned maintenance events. The accepted values are: `PERIODIC`.
The `guest_accelerator` block supports:
* `type` (Required) - The accelerator type resource to expose to this instance. E.g. `nvidia-tesla-k80`.