Hi All
Please help me on this , when I comment out the additional disk information from module and provided them from resource then I am not getting error but additional disk is not getting created only instance is created with boot disk.
Any idea on this ? how to attach this additional disk to instance.
resource “random_string” “add_disk_suffix” {
length = 4
number = true
min_numeric = 2
upper = false
special = false
}
module “gce” {
source = “xxx”
version = “xxx”
name = var.instance_name
project = var.gcp[var.environment].project_id
zone = var.zone
subnetwork_project = var.gcp[var.environment].network_project
subnetwork = var.gcp[var.environment].subnetwork
machine_type = var.machine_type
tags = “{split(",", var.tags)}"
source_image = var.source_image
source_image_project = var.source_image_project
service_account_email = var.gcp[var.environment].service_account
metadata = {
env = var.environment,
creator = var.vm_owner
}
metadata_startup_script = "{file(”./…/scripts/bootstrap.sh")}"
/* additional_disks = [{
name = “additional-disk-123”,
type = “pd-ssd”,
size = var.additional_disk_size,
description = “”,
labels = {},
mode = “READ_WRITE”,
device_name = “”,
disk_encryption_key_raw = “”,
kms_key_self_link = “”,
snapshot = “”,
provisioned_iops = 0,
resource_policies =
}] */
}
locals {
disk_name = “${var.instance_name}”
}
resource “google_compute_disk” “additional_disks” {
zone = var.zone
name = local.add_disk_name
type = “pd-ssd”
size = var.additional_disk_size
description = “”
labels = {}
#mode = “READ_WRITE”
snapshot = “”
provisioned_iops = 0
resource_policies =
depends_on = [
module.gce,
]
}
locals {
add_disk_name = “add-disk-${random_string.add_disk_suffix.result}”
}
Thanks,
Mahendra