Guest User

Untitled

a guest
Oct 12th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. Error: Error running plan: 1 error(s) occurred:
  2.  
  3. * azurerm_virtual_machine.main: 2 error(s) occurred:
  4.  
  5. * azurerm_virtual_machine.main[0]: Resource 'azurerm_network_interface.main' does not have attribute 'id' for variable 'azurerm_network_interface.main.*.id'
  6. * azurerm_virtual_machine.main[1]: Resource 'azurerm_network_interface.main' does not have attribute 'id' for variable 'azurerm_network_interface.main.*.id'
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14. resource "azurerm_network_interface" "main" {
  15. count = "${length(var.hostname)}"
  16. name = "${var.hostname[count.index]}-nic"
  17. location = "${azurerm_resource_group.main.*.location}"
  18. resource_group_name = "${azurerm_resource_group.main.*.name}"
  19.  
  20. ip_configuration {
  21. name = "${var.hostname[count.index]}-ipaddress"
  22. subnet_id = "${var.subnet[count.index]}"
  23. private_ip_address_allocation = "Dynamic"
  24. }
  25. }
  26.  
  27. resource "azurerm_virtual_machine" "main" {
  28. name = "${var.aplication}-${var.region[count.index]}-${var.hostname[count.index]}-vm"
  29. location = "${azurerm_resource_group.main.*.location}"
  30. resource_group_name = "${azurerm_resource_group.main.*.name}"
  31. network_interface_ids = ["${element(azurerm_network_interface.main.*.id, count.index)}"]
  32. vm_size = "Standard_DS1_v2"
  33.  
  34. # Uncomment this line to delete the OS disk automatically when deleting the VM
  35. delete_os_disk_on_termination = true
  36.  
  37. # Uncomment this line to delete the data disks automatically when deleting the VM
  38. # delete_data_disks_on_termination = true
  39.  
  40. storage_image_reference {
  41. publisher = "Canonical"
  42. offer = "UbuntuServer"
  43. sku = "16.04-LTS"
  44. version = "latest"
  45. }
  46.  
  47. storage_os_disk {
  48.  
  49. name = "osdisk"
  50. caching = "ReadWrite"
  51. create_option = "FromImage"
  52. managed_disk_type = "Standard_LRS"
  53. }
  54.  
  55. os_profile {
  56. computer_name = "${var.hostname[count.index]}"
  57. admin_username = "testadmin"
  58. admin_password = "Password1234!"
  59. }
  60.  
  61. os_profile_linux_config {
  62. disable_password_authentication = false
  63. }
  64.  
  65. tags {
  66. environment = "staging"
  67. }
  68. count = "${length(var.hostname)}"
  69. depends_on = ["azurerm_network_interface.main"]
  70. }
Add Comment
Please, Sign In to add comment