azurestack_virtual_machine_scale_set

Manages a virtual machine scale set.

Example Usage with Unmanaged Disks

resource "azurestack_resource_group" "test" {
  name     = "acctestRG"
  location = "West US"
}

resource "azurestack_virtual_network" "test" {
  name                = "acctvn"
  address_space       = ["10.0.0.0/16"]
  location            = "West US"
  resource_group_name = azurestack_resource_group.test.name
}

resource "azurestack_subnet" "test" {
  name                 = "acctsub"
  resource_group_name  = azurestack_resource_group.test.name
  virtual_network_name = azurestack_virtual_network.test.name
  address_prefix       = "10.0.2.0/24"
}

resource "azurestack_storage_account" "test" {
  name                     = "accsa"
  resource_group_name      = azurestack_resource_group.test.name
  location                 = "westus"
  account_tier             = "Standard"
  account_replication_type = "LRS"

  tags = {
    environment = "staging"
  }
}

resource "azurestack_storage_container" "test" {
  name                  = "vhds"
  resource_group_name   = azurestack_resource_group.test.name
  storage_account_name  = azurestack_storage_account.test.name
  container_access_type = "private"
}

resource "azurestack_virtual_machine_scale_set" "test" {
  name                = "mytestscaleset-1"
  location            = "West US"
  resource_group_name = azurestack_resource_group.test.name
  upgrade_policy_mode = "Manual"

  sku {
    name     = "Standard_A0"
    tier     = "Standard"
    capacity = 2
  }

  os_profile {
    computer_name_prefix = "testvm"
    admin_username       = "myadmin"
    admin_password       = "Passwword1234"
  }

  os_profile_linux_config {
    disable_password_authentication = true

    ssh_keys {
      path     = "/home/myadmin/.ssh/authorized_keys"
      key_data = "${file("~/.ssh/demo_key.pub")}"
    }
  }

  network_profile {
    name    = "TestNetworkProfile"
    primary = true

    ip_configuration {
      name      = "TestIPConfiguration"
      subnet_id = azurestack_subnet.test.id
    }
  }

  storage_profile_os_disk {
    name           = "osDiskProfile"
    caching        = "ReadWrite"
    create_option  = "FromImage"
    vhd_containers = ["${azurestack_storage_account.test.primary_blob_endpoint}${azurestack_storage_container.test.name}"]
  }

  storage_profile_image_reference {
    publisher = "Canonical"
    offer     = "UbuntuServer"
    sku       = "16.04-LTS"
    version   = "latest"
  }
}

Argument Reference

The following arguments are supported:

sku supports the following:

resource "azurestack_virtual_machine_scale_set" "test" {
  name                = "vm-scaleset"
  resource_group_name = "${azurestack_resource_group.test.name}"
  location            = "${azurestack_resource_group.test.location}"

  sku {
    name     = "${var.vm_sku}"
    tier     = "Standard"
    capacity = "${var.instance_count}"
  }

  identity {
    type = "systemAssigned"
  }

  extension {
    name                 = "MSILinuxExtension"
    publisher            = "Microsoft.ManagedIdentity"
    type                 = "ManagedIdentityExtensionForLinux"
    type_handler_version = "1.0"
    settings             = "{\"port\": 50342}"
  }

  output "principal_id" {
    value = "${lookup(azurestack_virtual_machine.test.identity[0], "principal_id")}"
  }
}

os_profile supports the following:

os_profile_secrets supports the following:

vault_certificates support the following:

os_profile_windows_config supports the following:

winrm supports the following:

additional_unattend_config supports the following:

os_profile_linux_config supports the following:

network_profile supports the following:

public_ip_address_configuration supports the following:

storage_profile_os_disk supports the following:

storage_profile_data_disk supports the following:

storage_profile_image_reference supports the following:

boot_diagnostics supports the following:

extension supports the following:

plan supports the following:

Example of storage_profile_image_reference with id

resource "azurestack_image" "test" {
  name = "test"

  #...
}

resource "azurestack_virtual_machine_scale_set" "test" {
  name = "test"

  #...

  storage_profile_image_reference {
    id = "${azurestack_image.test.id}"
  }

  #...
}

Attributes Reference

The following attributes are exported:

Import

Virtual Machine Scale Sets can be imported using the resource id, e.g.

terraform import azurestack_virtual_machine_scale_set.scaleset1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/virtualMachineScaleSets/scaleset1