我是Azure和Terraform的新手,但是我已经从离开我组织的人那里继承了一系列Terraform配置和模块。我的任务是将项目的VM更改为CIS强化版本,这要求我向我们的VM设置模块之一添加“计划”块:
resource "azurerm_virtual_machine" "vm-windows" {
count = "${(((var.vm_os_id != "" && var.is_windows_image == "true") || contains(list("${var.vm_os_simple}","${var.vm_os_offer}"), "WindowsServer")) && var.data_disk == "false") ? var.nb_instances : 0}"
name = "${var.vm_hostname}${count.index}"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
availability_set_id = "${azurerm_availability_set.vm.id}"
vm_size = "${var.vm_size}"
network_interface_ids = ["${element(azurerm_network_interface.vm.*.id, count.index)}"]
delete_os_disk_on_termination = "${var.delete_os_disk_on_termination}"
storage_image_reference {
id = "${var.vm_os_id}"
publisher = "${var.vm_os_id == "" ? coalesce(var.vm_os_publisher, module.os.calculated_value_os_publisher) : ""}"
offer = "${var.vm_os_id == "" ? coalesce(var.vm_os_offer, module.os.calculated_value_os_offer) : ""}"
sku = "${var.vm_os_id == "" ? coalesce(var.vm_os_sku, module.os.calculated_value_os_sku) : ""}"
version = "${var.vm_os_id == "" ? var.vm_os_version : ""}"
}
# this is what I added
plan {
name = "${var.vm_os_id == "" ? coalesce(var.vm_os_sku, module.os.calculated_value_os_sku) : ""}"
publisher = "${var.vm_os_id == "" ? coalesce(var.vm_os_publisher, module.os.calculated_value_os_publisher) : ""}"
product = "${var.vm_os_id == "" ? coalesce(var.vm_os_offer, module.os.calculated_value_os_offer) : ""}"
}
...
}
由于该模块是通用的(即,可用于具有无计划和需要计划的VM的项目使用),所以我需要了解更多有关此“计划”模块的信息。
到目前为止,我唯一看到的文档是Terraform's scant information on the block。它提供的信息不多(甚至没有参数名称),而且我也不知道如何将Azure的Terraform构造交叉引用。
答案 0 :(得分:1)