Я пытаюсь создать Windows VM в кластере с terraform, и я сталкиваюсь с ошибкой при создании
Ошибка
Error: Error applying plan:
1 error(s) occurred:
* module.vnet.azurerm_virtual_machine.vm[0]: 1 error(s) occurred:
* azurerm_virtual_machine.vm.0: Error determining IP Address for Virtual Machine "vm0" Error obtaining NIC "nic0"
network.InterfacesClient#Get: Ошибка отправки запроса: StatusCode = 0 - Исходная ошибка: Get wsarecv: Попытка подключения не удалась, потому что подключенная сторона не ответила должным образом через некоторое время, или не удалось установить соединение, потому что подключенный хост не смог ответить.
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
модуль terraform Я пытаюсь для простоты, я не добавляю, как vnet, группа ресурсов и т. Д. В следующем коде
resource "azurerm_lb_nat_rule" "tcp" {
resource_group_name = "${azurerm_resource_group.main.name}"
loadbalancer_id = "${azurerm_lb.main.id}"
name = "RDP-VM-${count.index}"
protocol = "tcp"
frontend_port = "5000${count.index + 1}"
backend_port = 3389
frontend_ip_configuration_name = "pip-${var.location_id}-${var.environment}-${var.cost_centre}-${var.project}-${var.seq_id}"
count = "${var.vm_count}"
}
resource "azurerm_lb_rule" "lb_rule" {
resource_group_name = "${azurerm_resource_group.main.name}"
loadbalancer_id = "${azurerm_lb.main.id}"
name = "lbrule-${var.location_id}-${var.environment}-${var.cost_centre}-${var.project}-${var.seq_id}"
protocol = "tcp"
frontend_port = 80
backend_port = 80
frontend_ip_configuration_name = "pip-${var.location_id}-${var.environment}-${var.cost_centre}-${var.project}-${var.seq_id}"
enable_floating_ip = false
backend_address_pool_id = "${azurerm_lb_backend_address_pool.main.id}"
idle_timeout_in_minutes = 5
probe_id = "${azurerm_lb_probe.main.id}"
depends_on = ["azurerm_lb_probe.main"]
}
resource "azurerm_network_interface" "main" {
name = "nic${count.index}"
location = "${azurerm_resource_group.main.location}"
resource_group_name = "${azurerm_resource_group.main.name}"
count = "${var.vm_count}"
ip_configuration {
name = "ipconfig${count.index}"
subnet_id = "${azurerm_subnet.main.id}"
private_ip_address_allocation = "Dynamic"
}
}
resource "azurerm_network_interface_nat_rule_association" "main" {
ip_configuration_name = "ipconfig${count.index}"
network_interface_id ="${element(azurerm_network_interface.main.*.id, count.index)}"
nat_rule_id = "${element(azurerm_lb_nat_rule.tcp.*.id, count.index)}"
count = "${var.vm_count}"
depends_on = ["azurerm_network_interface.main","azurerm_lb_nat_rule.tcp"]
}
resource "azurerm_network_interface_backend_address_pool_association" "main" {
network_interface_id ="${element(azurerm_network_interface.main.*.id, count.index)}"
ip_configuration_name = "ipconfig${count.index}"
backend_address_pool_id = "${azurerm_lb_backend_address_pool.main.id}"
count = "${var.vm_count}"
depends_on = ["azurerm_network_interface.main","azurerm_lb_backend_address_pool.main"]
}
resource "azurerm_virtual_machine" "vm" {
name = "vm${count.index}"
location = "${azurerm_resource_group.main.location}"
resource_group_name = "${azurerm_resource_group.main.name}"
availability_set_id = "${azurerm_availability_set.main.id}"
vm_size = "${var.vm_size}"
network_interface_ids = ["${element(azurerm_network_interface.main.*.id, count.index)}"]
count = "${var.vm_count}"
storage_image_reference {
publisher = "${var.image_publisher}"
offer = "${var.image_offer}"
sku = "${var.image_sku}"
version = "${var.image_version}"
}
storage_os_disk {
name = "osdisk${count.index}"
create_option = "FromImage"
}
os_profile {
computer_name = "${var.vm_name}-${count.index}"
admin_username = "${var.admin_username}"
admin_password = "${var.admin_password}"
}
os_profile_windows_config {}
}
iЯ использую вышеуказанный код в качестве модуля
module kofax-vnet{
//some variable values
location_id="euwest"
location="westeurope"
vnet_cidr_list=["10.125.0.0/16"]
subnet_cidr="10.125.0.0/20"
vm_count= "2"
vm_size="Standard_B4ms"
image_publisher="MicrosoftWindowsServer"
image_offer="WindowsServer"
image_sku="2016-Datacenter"
image_version="latest"
vm_name="myvm"
admin_username="someuser"
admin_password="somepassword"
}