terraform-provider-azureazure-availability-setazure-availability-zones

Error: "zone": conflicts with availability_set_id - Azure - Terraform


We have some Linux clusters (two machines each) running on Azure and we would like that each node of the cluster be created in different zones and using availability set.

We are trying to create the VM on Azure using Terraform:

resource "azurerm_linux_virtual_machine" "move-az-test" {
  count                            = "1"
  name                             = "move-az-test01"
  location                         = var.azure_location_short
  resource_group_name              = azurerm_resource_group.rg.name
  size                             = "Standard_B1S"
  zone                             = 1
  computer_name                    = "move-az01"
  disable_password_authentication  = true
  admin_username                   = var.os_user
  admin_password                   = var.os_password
  availability_set_id              = azurerm_availability_set.avset.id
  network_interface_ids            = [azurerm_network_interface.move-az-nic.id]

  source_image_reference {
    publisher = "OpenLogic"
    offer     = "CentOS"
    sku       = "7.6"
    version   = "latest"
  }

  os_disk {
    name                 = "move-az-test0_OsDisk"
    caching              = "ReadWrite"
    disk_size_gb         = "128"
    storage_account_type = "Standard_LRS"
  }
}

But we have the message error: Error: "zone": conflicts with availability_set_id


Solution

  • The short answer is that the availability set and the availability zone can't exist at the same time. You can take deeper learning about them. The former is in a logical grouping of the VMs and the latter improves the availability on the physical regions.