provider "azurerm" { } data "azurerm_network_security_group" "worker-nsg" { name = "worker-nsg" resource_group_name = "swh-resource" } data "azurerm_subnet" "default" { name = "default" virtual_network_name = "swh-vnet" resource_group_name = "swh-resource" } resource "azurerm_network_interface" "cassandra_vms_interfaces" { count = "${var.nb_cassandra_nodes}" name = "cassandra-${count.index}_interface" location = "westeurope" resource_group_name = "euwest-cassandra" network_security_group_id = "${data.azurerm_network_security_group.worker-nsg.id}" ip_configuration { name = "myNicConfiguration" subnet_id = "${data.azurerm_subnet.default.id}" public_ip_address_id = "" private_ip_address_allocation = "Dynamic" } } resource "azurerm_virtual_machine" "cassandra_vms" { count = "${var.nb_cassandra_nodes}" name = "cassandra-${count.index}" location = "westeurope" resource_group_name = "euwest-cassandra" network_interface_ids = [ "${element(azurerm_network_interface.cassandra_vms_interfaces.*.id, count.index)}"] vm_size = "Standard_B1s" storage_os_disk { name = "cassandra-${count.index}_osdisk" caching = "ReadWrite" create_option = "FromImage" managed_disk_type = "Premium_LRS" } storage_image_reference { publisher = "credativ" offer = "Debian" sku = "9" version = "latest" } os_profile { computer_name = "test-cassandra-${count.index}" admin_username = "vlorentz" } os_profile_linux_config { disable_password_authentication = true ssh_keys { path = "/home/vlorentz/.ssh/authorized_keys" key_data = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC1gRhavvtL92IIuXdVujwVnptT2aDlJafaDNrr7AVo2Eboc7MAlQC+9UHDpMqVhmLL3J9OFR7vSFMYjsRoREIB5wxsoTOQy5D2kZwbu28dMy7ZEM+gNFyQaGucngTSj0d3m80RVBYOMDupaXtPuw0fEzRKmHMOr3zMhCK8djbdMKIWnPMA2mxGjiCY22jd7k3jlGti3iXjZ+Mrl1VGKuOXiEpHsDNoQfL289odkP4nWQA95tS6Lwi2gUtSLmhu9QTfIoFVFwdGT8jLa3ql3Ia45otCDTH2SrI9ZYoUhmTDNwcVhhkpfCb8tbsU0zD6qSTn5EWHpv6+56oa3nLutgF1 azure@desktop5" } } storage_data_disk { name = "cassandra-${count.index}_datadisk" lun = 0 disk_size_gb = 1024 managed_disk_type = "Premium_LRS" create_option = "Empty" } }