Skip to content

Commit 5b5dd3e

Browse files
committed
updating creation of vm boot disk and coupling it with VM instance.
1 parent 2002926 commit 5b5dd3e

6 files changed

Lines changed: 12 additions & 43 deletions

File tree

community/modules/remote-desktop/chrome-remote-desktop/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ No resources.
7575
| Name | Description | Type | Default | Required |
7676
|------|-------------|------|---------|:--------:|
7777
| <a name="input_add_deployment_name_before_prefix"></a> [add\_deployment\_name\_before\_prefix](#input\_add\_deployment\_name\_before\_prefix) | If true, the names of VMs and disks will always be prefixed with `deployment_name` to enable uniqueness across deployments.<br/>See `name_prefix` for further details on resource naming behavior. | `bool` | `false` | no |
78-
| <a name="input_auto_delete_boot_disk"></a> [auto\_delete\_boot\_disk](#input\_auto\_delete\_boot\_disk) | Controls if boot disk should be auto-deleted when instance is deleted. | `bool` | `true` | no |
7978
| <a name="input_bandwidth_tier"></a> [bandwidth\_tier](#input\_bandwidth\_tier) | Tier 1 bandwidth increases the maximum egress bandwidth for VMs.<br/> Using the `tier_1_enabled` setting will enable both gVNIC and TIER\_1 higher bandwidth networking.<br/> Using the `gvnic_enabled` setting will only enable gVNIC and will not enable TIER\_1.<br/> Note that TIER\_1 only works with specific machine families & shapes and must be using an image th<br/>at supports gVNIC. See [official docs](https://cloud.google.com/compute/docs/networking/configure-v<br/>m-with-high-bandwidth-configuration) for more details. | `string` | `"not_enabled"` | no |
8079
| <a name="input_deployment_name"></a> [deployment\_name](#input\_deployment\_name) | Cluster Toolkit deployment name. Cloud resource names will include this value. | `string` | n/a | yes |
8180
| <a name="input_disk_size_gb"></a> [disk\_size\_gb](#input\_disk\_size\_gb) | Size of disk for instances. | `number` | `200` | no |

community/modules/remote-desktop/chrome-remote-desktop/main.tf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,9 @@ module "instances" {
9090
startup_script = module.client_startup_script.startup_script
9191
enable_oslogin = var.enable_oslogin
9292

93-
instance_image = var.instance_image
94-
disk_size_gb = var.disk_size_gb
95-
disk_type = var.disk_type
96-
auto_delete_boot_disk = var.auto_delete_boot_disk
93+
instance_image = var.instance_image
94+
disk_size_gb = var.disk_size_gb
95+
disk_type = var.disk_type
9796

9897
disable_public_ips = !var.enable_public_ips
9998
network_self_link = var.network_self_link

community/modules/remote-desktop/chrome-remote-desktop/variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,6 @@ variable "disk_type" {
8787
default = "pd-balanced"
8888
}
8989

90-
variable "auto_delete_boot_disk" {
91-
description = "Controls if boot disk should be auto-deleted when instance is deleted."
92-
type = bool
93-
default = true
94-
}
95-
9690
variable "name_prefix" {
9791
description = <<-EOT
9892
An optional name for all VM and disk resources.

modules/compute/vm-instance/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ limitations under the License.
196196
| [google-beta_google_compute_resource_policy.placement_policy](https://registry.terraform.io/providers/hashicorp/google-beta/latest/docs/resources/google_compute_resource_policy) | resource |
197197
| [google_compute_address.compute_ip](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_address) | resource |
198198
| [google_compute_disk.additional_disks](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_disk) | resource |
199-
| [google_compute_disk.boot_disk](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_disk) | resource |
200199
| [null_resource.image](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
201200
| [null_resource.replace_vm_trigger_from_placement](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
202201
| [google_compute_image.compute_image](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_image) | data source |
@@ -209,7 +208,6 @@ limitations under the License.
209208
| <a name="input_additional_persistent_disks"></a> [additional\_persistent\_disks](#input\_additional\_persistent\_disks) | Configurations of additional disks to be included on the partition nodes. | <pre>object({<br/> count = optional(number, 0)<br/> type = optional(string, "pd-balanced")<br/> size = optional(number, 200)<br/> })</pre> | `{}` | no |
210209
| <a name="input_allocate_ip"></a> [allocate\_ip](#input\_allocate\_ip) | If not null, allocate IPs with the given configuration. See details at<br/>https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_address | <pre>object({<br/> address_type = optional(string, "INTERNAL")<br/> purpose = optional(string),<br/> network_tier = optional(string),<br/> ip_version = optional(string, "IPV4"),<br/> })</pre> | `null` | no |
211210
| <a name="input_allow_automatic_updates"></a> [allow\_automatic\_updates](#input\_allow\_automatic\_updates) | If false, disables automatic system package updates on the created instances. This feature is<br/>only available on supported images (or images derived from them). For more details, see<br/>https://cloud.google.com/compute/docs/instances/create-hpc-vm#disable_automatic_updates | `bool` | `true` | no |
212-
| <a name="input_auto_delete_boot_disk"></a> [auto\_delete\_boot\_disk](#input\_auto\_delete\_boot\_disk) | Controls if boot disk should be auto-deleted when instance is deleted. | `bool` | `true` | no |
213211
| <a name="input_automatic_restart"></a> [automatic\_restart](#input\_automatic\_restart) | Specifies if the instance should be restarted if it was terminated by Compute Engine (not a user). | `bool` | `null` | no |
214212
| <a name="input_bandwidth_tier"></a> [bandwidth\_tier](#input\_bandwidth\_tier) | Tier 1 bandwidth increases the maximum egress bandwidth for VMs.<br/> Using the `tier_1_enabled` setting will enable both gVNIC and TIER\_1 higher bandwidth networking.<br/> Using the `gvnic_enabled` setting will only enable gVNIC and will not enable TIER\_1.<br/> 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 |
215213
| <a name="input_deployment_name"></a> [deployment\_name](#input\_deployment\_name) | Name of the deployment, will optionally be used name resources according to `name_prefix` | `string` | n/a | yes |

modules/compute/vm-instance/main.tf

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -112,27 +112,6 @@ resource "null_resource" "image" {
112112
}
113113
}
114114

115-
resource "google_compute_disk" "boot_disk" {
116-
project = var.project_id
117-
118-
count = var.instance_count
119-
120-
name = "${local.resource_prefix}-boot-disk-${count.index}"
121-
image = data.google_compute_image.compute_image.self_link
122-
type = var.disk_type
123-
size = var.disk_size_gb
124-
labels = local.labels
125-
zone = var.zone
126-
127-
lifecycle {
128-
replace_triggered_by = [null_resource.image]
129-
130-
ignore_changes = [
131-
image
132-
]
133-
}
134-
}
135-
136115
resource "google_compute_disk" "additional_disks" {
137116
project = var.project_id
138117

@@ -205,9 +184,15 @@ resource "google_compute_instance" "compute_vm" {
205184
labels = local.labels
206185

207186
boot_disk {
208-
source = google_compute_disk.boot_disk[count.index].self_link
209-
device_name = google_compute_disk.boot_disk[count.index].name
210-
auto_delete = var.auto_delete_boot_disk
187+
initialize_params {
188+
image = data.google_compute_image.compute_image.self_link
189+
size = var.disk_size_gb
190+
type = var.disk_type
191+
labels = local.labels
192+
}
193+
194+
device_name = "${local.resource_prefix}-boot-disk-${count.index}"
195+
auto_delete = true
211196
}
212197

213198
dynamic "attached_disk" {

modules/compute/vm-instance/variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ variable "disk_type" {
5656
default = "pd-standard"
5757
}
5858

59-
variable "auto_delete_boot_disk" {
60-
description = "Controls if boot disk should be auto-deleted when instance is deleted."
61-
type = bool
62-
default = true
63-
}
64-
6559
variable "local_ssd_count" {
6660
description = "The number of local SSDs to attach to each VM. See https://cloud.google.com/compute/docs/disks/local-ssd."
6761
type = number

0 commit comments

Comments
 (0)