如何将托管数据磁盘(要连接到VM的空数据磁盘)添加到VM?
输入:将创建一个资源组,并手动创建虚拟网络和子网并将其添加到该资源组。
输出:为应用程序服务器创建另一个资源组,该资源组应包含:
要配置5个VM。我有一个问题,当我尝试向5个VM的每一个中添加1 TB磁盘时,它会出错。
预期结果::已配置VM,并将数据磁盘添加到5个节点(每个节点具有1 TB * 5个磁盘)的VM群集中。
我在下面的相关摘录中提供了错误信息。
代码:
# Storage Account
resource "azurerm_storage_account" "tf-sa-cluster-aos" {
count=5
name = "${lower(var.ax_base_hostname)}${count.index+1}stoacc"
location = "${azurerm_resource_group.tf-rg-cluster-aos.location}"
resource_group_name = "${azurerm_resource_group.tf-rg-cluster-aos.name}"
account_tier = "${var.sto_acc_tier_std}"
account_replication_type = "${var.sto_acc_rep_type_lrs}"
tags {
environment = "${var.env}"
}
}
Optional Managed Data Disk
resource "azurerm_managed_disk" "tf-mdsk-cluster" {
count = 5
name = "${var.ax_base_hostname}-DATADISK-${count.index+1}"
location = "${azurerm_resource_group.tf-rg-cluster-aos.location}"
resource_group_name = "${azurerm_resource_group.tf-rg-cluster-aos.name}"
storage_account_type = "Standard_LRS"
create_option = "Empty"
disk_size_gb = "2048"
}
resource "azurerm_virtual_machine" "tf-vm-cluster-aos" {
count = 5
name = "${var.ax_base_hostname}-${count.index+1}"
location = "${azurerm_resource_group.tf-rg-cluster-aos.location}"
resource_group_name = "${azurerm_resource_group.tf-rg-cluster-aos.name}"
availability_set_id = "${azurerm_availability_set.tf-as-cluster-aos.id}"
network_interface_ids = ["${element(azurerm_network_interface.tf-ni-cluster-aos.*.id, count.index+1)}"]
vm_size = "${var.ax_vm_size}"
storage_data_disk {
name = "${element(azurerm_managed_disk.tf-mdsk-cluster.*.name, count.index+1)}"
managed_disk_id = "${element(azurerm_managed_disk.tf-mdsk-cluster.*.id, count.index+1)}"
create_option = "Attach"
lun = 0
disk_size_gb = "${element(azurerm_managed_disk.tf-mdsk-cluster.*.disk_size_gb, count.index+1)}"
}
}
错误:
错误:未知的根级密钥:可选
错误:资源'azurerm_virtual_machine.tf-vm-cluster-aos'配置:未知资源'azurerm_managed_disk.tf-mdsk-cluster'在变量azu rerm_managed_disk.tf-mdsk-cluster。*。id
中引用错误:资源'azurerm_virtual_machine.tf-vm-cluster-aos'配置:未知资源'azurerm_managed_disk.tf-mdsk-cluster'在变量azu rerm_managed_disk.tf-mdsk-cluster。*。disk_size_gb
中引用错误:资源'azurerm_virtual_machine.tf-vm-cluster-aos'配置:未知资源'azurerm_managed_disk.tf-mdsk-cluster'在变量azu rerm_managed_disk.tf-mdsk-cluster。*。name中引用