diff --git a/modules/compute-vm/README.md b/modules/compute-vm/README.md
index 1928a8dce..226dd15a7 100644
--- a/modules/compute-vm/README.md
+++ b/modules/compute-vm/README.md
@@ -917,10 +917,10 @@ module "sole-tenancy" {
| name | description | type | required | default |
|---|---|:---:|:---:|:---:|
-| [name](variables.tf#L264) | Instance name. | string | ✓ | |
-| [network_interfaces](variables.tf#L276) | Network interfaces configuration. Use self links for Shared VPC, set addresses to null if not needed. | list(object({…})) | ✓ | |
-| [project_id](variables.tf#L345) | Project id. | string | ✓ | |
-| [zone](variables.tf#L443) | Compute zone. | string | ✓ | |
+| [name](variables.tf#L267) | Instance name. | string | ✓ | |
+| [network_interfaces](variables.tf#L279) | Network interfaces configuration. Use self links for Shared VPC, set addresses to null if not needed. | list(object({…})) | ✓ | |
+| [project_id](variables.tf#L352) | Project id. | string | ✓ | |
+| [zone](variables.tf#L450) | Compute zone. | string | ✓ | |
| [attached_disk_defaults](variables.tf#L17) | Defaults for attached disks options. | object({…}) | | {…} |
| [attached_disks](variables.tf#L37) | Additional disks, if options is null defaults will be used in its place. Source type is one of 'image' (zonal disks in vms and template), 'snapshot' (vm), 'existing', and null. | list(object({…})) | | [] |
| [boot_disk](variables.tf#L83) | Boot disk properties. | object({…}) | | {…} |
@@ -931,23 +931,23 @@ module "sole-tenancy" {
| [enable_display](variables.tf#L140) | Enable virtual display on the instances. | bool | | false |
| [encryption](variables.tf#L146) | Encryption options. Only one of kms_key_self_link and disk_encryption_key_raw may be set. If needed, you can specify to encrypt or not the boot disk. | object({…}) | | null |
| [gpu](variables.tf#L156) | GPU information. Based on https://cloud.google.com/compute/docs/gpus. | object({…}) | | null |
-| [group](variables.tf#L185) | Define this variable to create an instance group for instances. Disabled for template use. | object({…}) | | null |
-| [hostname](variables.tf#L193) | Instance FQDN name. | string | | null |
-| [iam](variables.tf#L199) | IAM bindings in {ROLE => [MEMBERS]} format. | map(list(string)) | | {} |
-| [instance_schedule](variables.tf#L205) | Assign or create and assign an instance schedule policy. Either resource policy id or create_config must be specified if not null. Set active to null to dtach a policy from vm before destroying. | object({…}) | | null |
-| [instance_type](variables.tf#L240) | Instance type. | string | | "f1-micro" |
-| [labels](variables.tf#L246) | Instance labels. | map(string) | | {} |
-| [metadata](variables.tf#L252) | Instance metadata. | map(string) | | {} |
-| [min_cpu_platform](variables.tf#L258) | Minimum CPU platform. | string | | null |
-| [network_attached_interfaces](variables.tf#L269) | Network interfaces using network attachments. | list(string) | | [] |
-| [options](variables.tf#L292) | Instance options. | object({…}) | | {…} |
-| [scratch_disks](variables.tf#L350) | Scratch disks configuration. | object({…}) | | {…} |
-| [service_account](variables.tf#L362) | Service account email and scopes. If email is null, the default Compute service account will be used unless auto_create is true, in which case a service account will be created. Set the variable to null to avoid attaching a service account. | object({…}) | | {} |
-| [shielded_config](variables.tf#L372) | Shielded VM configuration of the instances. | object({…}) | | null |
-| [snapshot_schedules](variables.tf#L382) | Snapshot schedule resource policies that can be attached to disks. | map(object({…})) | | {} |
-| [tag_bindings](variables.tf#L425) | Resource manager tag bindings for this instance, in tag key => tag value format. | map(string) | | null |
-| [tag_bindings_firewall](variables.tf#L431) | Firewall (network scoped) tag bindings for this instance, in tag key => tag value format. | map(string) | | null |
-| [tags](variables.tf#L437) | Instance network tags for firewall rule targets. | list(string) | | [] |
+| [group](variables.tf#L188) | Define this variable to create an instance group for instances. Disabled for template use. | object({…}) | | null |
+| [hostname](variables.tf#L196) | Instance FQDN name. | string | | null |
+| [iam](variables.tf#L202) | IAM bindings in {ROLE => [MEMBERS]} format. | map(list(string)) | | {} |
+| [instance_schedule](variables.tf#L208) | Assign or create and assign an instance schedule policy. Either resource policy id or create_config must be specified if not null. Set active to null to dtach a policy from vm before destroying. | object({…}) | | null |
+| [instance_type](variables.tf#L243) | Instance type. | string | | "f1-micro" |
+| [labels](variables.tf#L249) | Instance labels. | map(string) | | {} |
+| [metadata](variables.tf#L255) | Instance metadata. | map(string) | | {} |
+| [min_cpu_platform](variables.tf#L261) | Minimum CPU platform. | string | | null |
+| [network_attached_interfaces](variables.tf#L272) | Network interfaces using network attachments. | list(string) | | [] |
+| [options](variables.tf#L295) | Instance options. | object({…}) | | {…} |
+| [scratch_disks](variables.tf#L357) | Scratch disks configuration. | object({…}) | | {…} |
+| [service_account](variables.tf#L369) | Service account email and scopes. If email is null, the default Compute service account will be used unless auto_create is true, in which case a service account will be created. Set the variable to null to avoid attaching a service account. | object({…}) | | {} |
+| [shielded_config](variables.tf#L379) | Shielded VM configuration of the instances. | object({…}) | | null |
+| [snapshot_schedules](variables.tf#L389) | Snapshot schedule resource policies that can be attached to disks. | map(object({…})) | | {} |
+| [tag_bindings](variables.tf#L432) | Resource manager tag bindings for this instance, in tag key => tag value format. | map(string) | | null |
+| [tag_bindings_firewall](variables.tf#L438) | Firewall (network scoped) tag bindings for this instance, in tag key => tag value format. | map(string) | | null |
+| [tags](variables.tf#L444) | Instance network tags for firewall rule targets. | list(string) | | [] |
## Outputs
diff --git a/modules/compute-vm/main.tf b/modules/compute-vm/main.tf
index bf215af06..daf160390 100644
--- a/modules/compute-vm/main.tf
+++ b/modules/compute-vm/main.tf
@@ -313,6 +313,21 @@ resource "google_compute_instance" "default" {
values = affinity.value.values
}
}
+
+ dynamic "graceful_shutdown" {
+ for_each = var.options.graceful_shutdown != null ? [""] : []
+ content {
+ enabled = var.options.graceful_shutdown.enabled
+ dynamic "max_duration" {
+ for_each = var.options.graceful_shutdown.enabled == true && var.options.graceful_shutdown.max_duration_secs != null ? [""] : []
+ content {
+ seconds = var.options.graceful_shutdown.max_duration_secs
+ nanos = 0
+ }
+ }
+ }
+ }
+
}
dynamic "scratch_disk" {
@@ -519,6 +534,20 @@ resource "google_compute_instance_template" "default" {
values = affinity.value.values
}
}
+
+ dynamic "graceful_shutdown" {
+ for_each = var.options.graceful_shutdown != null ? [""] : []
+ content {
+ enabled = var.options.graceful_shutdown.enabled
+ dynamic "max_duration" {
+ for_each = var.options.graceful_shutdown.enabled == true && var.options.graceful_shutdown.max_duration_secs != null ? [""] : []
+ content {
+ seconds = var.options.graceful_shutdown.max_duration_secs
+ nanos = 0
+ }
+ }
+ }
+ }
}
dynamic "service_account" {
diff --git a/modules/compute-vm/variables.tf b/modules/compute-vm/variables.tf
index 6e84daa84..4f040587f 100644
--- a/modules/compute-vm/variables.tf
+++ b/modules/compute-vm/variables.tf
@@ -173,12 +173,15 @@ variable "gpu" {
"nvidia-tesla-p4",
"nvidia-tesla-t4",
"nvidia-l4",
- "nvidia-a2"
+ "nvidia-a2",
+ "nvidia-tesla-t4-vws",
+ "nvidia-tesla-p100-vws",
+ "nvidia-tesla-p4-vws"
],
try(var.gpu.type, "-")
)
)
- error_message = "GPU type must be one of the allowed values: nvidia-tesla-a100, nvidia-tesla-p100, nvidia-tesla-v100, nvidia-tesla-k80, nvidia-tesla-p4, nvidia-tesla-t4, nvidia-l4, nvidia-a2."
+ error_message = "GPU type must be one of the allowed values: nvidia-tesla-a100, nvidia-tesla-p100, nvidia-tesla-v100, nvidia-tesla-k80, nvidia-tesla-p4, nvidia-tesla-t4, nvidia-l4, nvidia-a2, nvidia-tesla-t4-vws, nvidia-tesla-p100-vws, nvidia-tesla-p4-vws."
}
}
@@ -302,6 +305,10 @@ variable "options" {
}))
allow_stopping_for_update = optional(bool, true)
deletion_protection = optional(bool, false)
+ graceful_shutdown = optional(object({
+ enabled = optional(bool, false)
+ max_duration_secs = optional(number)
+ }))
max_run_duration = optional(object({
nanos = optional(number)
seconds = number
@@ -444,5 +451,3 @@ variable "zone" {
description = "Compute zone."
type = string
}
-
-