【发布时间】:2021-08-28 14:08:54
【问题描述】:
我正在尝试使用 terraform 在 gcp 中创建一个带有 boot_disk 和附加 attach_disk 的 vm 实例。当实例被删除时,我找不到任何参数来自动删除附加的附加磁盘。
地形代码:
resource "google_compute_disk" "elastic-disk" {
count = var.no_of_elastic_intances
name = "elastic-disk-${count.index+1}-data"
type = "pd-standard"
size = "10"
}
resource "google_compute_instance" "elastic" {
count = var.no_of_elastic_intances
name = "${var.elastic_instance_name_prefix}-${count.index+1}"
machine_type = var.elastic_instance_machine_type
boot_disk {
auto_delete = true
mode = "READ_WRITE"
initialize_params {
image = var.elastic_instance_image_type
type = var.elastic_instance_disc_type
size = var.elasitc_instance_disc_size
}
}
attached_disk {
source = "${element(google_compute_disk.elastic-disk.*.self_link, count.index)}"
mode = "READ_WRITE"
}
network_interface {
network = var.elastic_instance_network
access_config {
}
}
}
【问题讨论】:
标签: google-cloud-platform terraform terraform-provider-gcp