Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Error: Error running plan: 1 error(s) occurred:
- * azurerm_virtual_machine.main: 2 error(s) occurred:
- * azurerm_virtual_machine.main[0]: Resource 'azurerm_network_interface.main' does not have attribute 'id' for variable 'azurerm_network_interface.main.*.id'
- * azurerm_virtual_machine.main[1]: Resource 'azurerm_network_interface.main' does not have attribute 'id' for variable 'azurerm_network_interface.main.*.id'
- resource "azurerm_network_interface" "main" {
- count = "${length(var.hostname)}"
- name = "${var.hostname[count.index]}-nic"
- location = "${azurerm_resource_group.main.*.location}"
- resource_group_name = "${azurerm_resource_group.main.*.name}"
- ip_configuration {
- name = "${var.hostname[count.index]}-ipaddress"
- subnet_id = "${var.subnet[count.index]}"
- private_ip_address_allocation = "Dynamic"
- }
- }
- resource "azurerm_virtual_machine" "main" {
- name = "${var.aplication}-${var.region[count.index]}-${var.hostname[count.index]}-vm"
- location = "${azurerm_resource_group.main.*.location}"
- resource_group_name = "${azurerm_resource_group.main.*.name}"
- network_interface_ids = ["${element(azurerm_network_interface.main.*.id, count.index)}"]
- vm_size = "Standard_DS1_v2"
- # Uncomment this line to delete the OS disk automatically when deleting the VM
- delete_os_disk_on_termination = true
- # Uncomment this line to delete the data disks automatically when deleting the VM
- # delete_data_disks_on_termination = true
- storage_image_reference {
- publisher = "Canonical"
- offer = "UbuntuServer"
- sku = "16.04-LTS"
- version = "latest"
- }
- storage_os_disk {
- name = "osdisk"
- caching = "ReadWrite"
- create_option = "FromImage"
- managed_disk_type = "Standard_LRS"
- }
- os_profile {
- computer_name = "${var.hostname[count.index]}"
- admin_username = "testadmin"
- admin_password = "Password1234!"
- }
- os_profile_linux_config {
- disable_password_authentication = false
- }
- tags {
- environment = "staging"
- }
- count = "${length(var.hostname)}"
- depends_on = ["azurerm_network_interface.main"]
- }
Add Comment
Please, Sign In to add comment