Skip to content

Commit cb0df01

Browse files
authored
Merge pull request GoogleCloudPlatform#4558 from arpit974/update_vm_boot_disk_logic
Update vm boot disk and coupling it with VM instance
2 parents 4cf3752 + 17ecceb commit cb0df01

2 files changed

Lines changed: 8 additions & 24 deletions

File tree

modules/compute/vm-instance/README.md

Lines changed: 0 additions & 1 deletion
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 |

modules/compute/vm-instance/main.tf

Lines changed: 8 additions & 23 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,8 +184,14 @@ 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
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}"
210195
auto_delete = var.auto_delete_boot_disk
211196
}
212197

0 commit comments

Comments
 (0)