hashicorp / terraform-provider-azurestack

Terraform provider for Azure Stack
https://www.terraform.io/docs/providers/azurestack/
Mozilla Public License 2.0
40 stars 64 forks source link

Sku "Aligned" not available for Availability Set #100

Closed LynxPantera closed 5 years ago

LynxPantera commented 5 years ago

Hi all,

We tried to create Availability Sets with VMs having managed disks. Unfortunately we have an error, specifying that the Availability Sets must have the Sku "Aligned". However, according to the Provider's source code, this option is not available (apparently commented).

Would it be possible to add this feature?

Error with Terraform:

Error: compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status= Code="OperationNotAllowed" Message="Addition of a VM with managed disks to non-managed Availability Set or addition of a VM with blob based disks to managed Availability Set is not supported. Please create an Availability Set with 'Aligned' SKU in order to add a VM with managed disks to it." Target="vm-test-001"

EtienneDeneuve commented 5 years ago

@LynxPantera can you send your template to check something ?

LynxPantera commented 5 years ago

Hi @EtienneDeneuve, Here is my main.tf file:

provider "azurestack" {
  arm_endpoint    = "_arm_endpoint_"
  subscription_id = "_subscription_id_"
  client_id       = "_client_id_"
  client_secret   = "_client_secret_"
  tenant_id       = "_tenant_id_"
}

resource "azurestack_resource_group" "rg" {
  count    = "1"
  name     = "rg-test"
  location = "location01"
}

resource "azurestack_subnet" "sn" {
  count                = "1"
  name                 = "sn-test"
  resource_group_name  = "rg-azs-test"
  virtual_network_name = "vn-azs-test"
  address_prefix       = "10.0.0.0/24"
}

resource "azurestack_network_security_group" "nsg" {
    count               = "1"
    name                = "nsg-test"
    location            = "location01"
    resource_group_name = "${azurestack_resource_group.rg.*.name[0]}"
}

resource "azurestack_public_ip" "ip" {
  count                        = "4"
  name                         = "ip-test-${count.index}"
  location                     = "location01"
  resource_group_name          = "${azurestack_resource_group.rg.*.name[0]}"
  public_ip_address_allocation = "static"
}

resource "azurestack_network_interface" "nic" {
  count                     = "4"
  name                      = "nic-test-${count.index}"
  location                  = "location01"
  resource_group_name       = "${azurestack_resource_group.rg.*.name[0]}"
  network_security_group_id = "${azurestack_network_security_group.nsg.*.id[0]}"

  ip_configuration {
      name                          = "ipconfig0"
      subnet_id                     = "${azurestack_subnet.sn.*.id[0]}"
      private_ip_address_allocation = "dynamic"
      public_ip_address_id          = "${element(concat(azurestack_public_ip.ip.*.id, list("")), count.index)}"
  }
}

resource "random_id" "randomId" {
    count       = "4"
    keepers     = {
                resource_group = "tst-${count.index}"
    }
    byte_length = 8
}

resource "azurestack_storage_account" "sa" {
    count                    = "4"
    name                     = "diag${element(random_id.randomId.*.hex, count.index)}"
    resource_group_name      = "${azurestack_resource_group.rg.*.name[0]}"
    location                 = "location01"
    account_replication_type = "LRS"
    account_tier             = "Standard"
}

resource "azurestack_virtual_machine" "vm" {
    count                 = "4"
    name                  = "vm-test-${count.index}"
    location              = "location01"
    resource_group_name   = "${azurestack_resource_group.rg.*.name[0]}"
    network_interface_ids = ["${element(azurestack_network_interface.nic.*.id, count.index)}"]
    vm_size               = "Standard_F4s"
    availability_set_id   = "${azurestack_availability_set.as.*.id[0]}"

    storage_os_disk {
        name              = "vm-test-${count.index}-osdisk"
        caching           = "ReadWrite"
        create_option     = "FromImage"
        managed_disk_type = "Standard_LRS"
    }

    storage_data_disk {
        name              = "data-test-${count.index}"
        create_option     = "Empty"
        caching           = "ReadWrite"
        lun               = 0
        disk_size_gb      = "100"
        managed_disk_type = "Standard_LRS"
    }

    storage_image_reference {
        publisher = "OpenLogic"
        offer     = "CentOS"
        sku       = "7.5"
        version   = "latest"
    }

    os_profile {
        computer_name  = "vm-test-${count.index}"
        admin_username = "_login_"
        admin_password = "_password_wq"
    }

    os_profile_linux_config {
        disable_password_authentication = false
    }

    boot_diagnostics {
        enabled     = "true"
        storage_uri = "${element(azurestack_storage_account.sa.*.primary_blob_endpoint, count.index)}"
    }
}
jbmcfarlin31 commented 5 years ago

@LynxPantera @EtienneDeneuve I tried the same thing and got the same result... this would definitely be a +1 as we are moving to managed disks as well!

jbmcfarlin31 commented 5 years ago

@LynxPantera @EtienneDeneuve I actually got this working in my own repo... my azure stack instance is running the latest build 1907 so I had to make some dependency changes, but I am able to compile the go binary and use the provider in my terraform configuration using managed = true for my availability set.

My repo can be found here: Terraform azure stack provider

On a side note, @tombuildsstuff is the managed availability sets going to be released in the v0.9.0 release?

petems commented 5 years ago

@jbmcfarlin31 Your change seems like it resolves the issue! I've just rebased it and opened as a PR

ghost commented 5 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!