我是 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) : ""}"
}
...
}
由于该模块是通用的(即,可供具有无计划和需要计划的虚拟机的项目使用),我需要了解更多关于这个“计划”块的信息。
- 它是什么,我在哪里可以阅读更多关于它的信息?(对于 Google 来说,这似乎是一件困难的事情;例如,“azure virtual machine plan”会产生定价信息。)
- 为不一定需要它的虚拟机保留该块是否合适?
到目前为止,我看到的唯一文档是Terraform 关于 block 的少量信息。它没有提供太多信息(甚至没有提供参数名称),而且我不知道如何将 Terraform 构造与 Azure 交叉引用。