From 93a703a1898866bf9abd409896220e1440cd2025 Mon Sep 17 00:00:00 2001 From: Nick Stroud Date: Tue, 13 Sep 2022 15:45:04 -0700 Subject: [PATCH] Add auto-delete boot disk as an option on vm-instance --- modules/compute/vm-instance/README.md | 1 + modules/compute/vm-instance/main.tf | 2 +- modules/compute/vm-instance/variables.tf | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/compute/vm-instance/README.md b/modules/compute/vm-instance/README.md index 34b390d1f9..69bd9d198c 100644 --- a/modules/compute/vm-instance/README.md +++ b/modules/compute/vm-instance/README.md @@ -134,6 +134,7 @@ No modules. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| +| [auto\_delete\_boot\_disk](#input\_auto\_delete\_boot\_disk) | Controlls if boot disk should be auto-deleted when instance is deleted. | `bool` | `true` | no | | [bandwidth\_tier](#input\_bandwidth\_tier) | Tier 1 bandwidth increases the maximum egress bandwidth for VMs.
Using the `tier_1_enabled` setting will enable both gVNIC and TIER\_1 higher bandwidth networking.
Using the `gvnic_enabled` setting will only enable gVNIC and will not enable TIER\_1.
Note that TIER\_1 only works with specific machine families & shapes and must be using an image that supports gVNIC. See [official docs](https://cloud.google.com/compute/docs/networking/configure-vm-with-high-bandwidth-configuration) for more details. | `string` | `"not_enabled"` | no | | [deployment\_name](#input\_deployment\_name) | Name of the deployment, used to name the cluster | `string` | n/a | yes | | [disable\_public\_ips](#input\_disable\_public\_ips) | If set to true, instances will not have public IPs | `bool` | `false` | no | diff --git a/modules/compute/vm-instance/main.tf b/modules/compute/vm-instance/main.tf index 213b453e5c..f00d8f8f89 100644 --- a/modules/compute/vm-instance/main.tf +++ b/modules/compute/vm-instance/main.tf @@ -112,7 +112,7 @@ resource "google_compute_instance" "compute_vm" { boot_disk { source = google_compute_disk.boot_disk[count.index].self_link device_name = google_compute_disk.boot_disk[count.index].name - auto_delete = true + auto_delete = var.auto_delete_boot_disk } dynamic "scratch_disk" { diff --git a/modules/compute/vm-instance/variables.tf b/modules/compute/vm-instance/variables.tf index d5e5126e2c..fb368815f1 100644 --- a/modules/compute/vm-instance/variables.tf +++ b/modules/compute/vm-instance/variables.tf @@ -49,6 +49,12 @@ variable "disk_type" { default = "pd-standard" } +variable "auto_delete_boot_disk" { + description = "Controlls if boot disk should be auto-deleted when instance is deleted." + type = bool + default = true +} + variable "local_ssd_count" { description = "The number of local SSDs to attach to each VM. See https://cloud.google.com/compute/docs/disks/local-ssd." type = number