azurerm_linux_virtual_machine_scale_set

Manages a Linux Virtual Machine Scale Set.

Disclaimers

Example Usage

This example provisions a basic Linux Virtual Machine Scale Set on an internal network. Additional examples of how to use the azurerm_linux_virtual_machine_scale_set resource can be found in the ./examples/vm-scale-set/linux` directory within the GitHub Repository.

locals {
  first_public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+wWK73dCr+jgQOAxNsHAnNNNMEMWOHYEccp6wJm2gotpr9katuF/ZAdou5AaW1C61slRkHRkpRRX9FA9CYBiitZgvCCz+3nWNN7l/Up54Zps/pHWGZLHNJZRYyAB6j5yVLMVHIHriY49d/GZTZVNB8GoJv9Gakwc/fuEZYYl4YDFiGMBP///TzlI4jhiJzjKnEvqPFki5p2ZRJqcbCiF4pJrxUQR/RXqVFQdbRLZgYfJ8xGB878RENq3yQ39d8dVOkq4edbkzwcUmwwwkYVPIoDGsYLaRHnG+To7FvMeyO7xDVQkMKzopTQV8AuKpyvpqu0a9pWOMaiCyDytO7GGN you@me.com"
}

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_virtual_network" "example" {
  name                = "example-network"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
  address_space       = ["10.0.0.0/16"]
}

resource "azurerm_subnet" "internal" {
  name                 = "internal"
  resource_group_name  = azurerm_resource_group.example.name
  virtual_network_name = azurerm_virtual_network.example.name
  address_prefixes     = ["10.0.2.0/24"]
}

resource "azurerm_linux_virtual_machine_scale_set" "example" {
  name                = "example-vmss"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
  sku                 = "Standard_F2"
  instances           = 1
  admin_username      = "adminuser"

  admin_ssh_key {
    username   = "adminuser"
    public_key = local.first_public_key
  }

  source_image_reference {
    publisher = "Canonical"
    offer     = "0001-com-ubuntu-server-jammy"
    sku       = "22_04-lts"
    version   = "latest"
  }

  os_disk {
    storage_account_type = "Standard_LRS"
    caching              = "ReadWrite"
  }

  network_interface {
    name    = "example"
    primary = true

    ip_configuration {
      name      = "internal"
      primary   = true
      subnet_id = azurerm_subnet.internal.id
    }
  }
}

Argument Reference



An additional_capabilities block supports the following:


An admin_ssh_key block supports the following:


An automatic_os_upgrade_policy block supports the following:


An automatic_instance_repair block supports the following:


A boot_diagnostics block supports the following:


A certificate block supports the following:


A data_disk block supports the following:


A diff_disk_settings block supports the following:


An extension block supports the following:


A gallery_application block supports the following:


An identity block supports the following:


An ip_configuration block supports the following:


An ip_tag block supports the following:


A network_interface block supports the following:


An os_disk block supports the following:


A plan block supports the following:


A protected_settings_from_key_vault block supports the following:


A scale_in block supports the following:


A public_ip_address block supports the following:


A rolling_upgrade_policy block supports the following:


A secret block supports the following:


A terminate_notification block supports the following:


A termination_notification block supports the following:


A source_image_reference block supports the following:


A spot_restore block supports the following:


Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:


A identity block exports the following:

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

Import

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

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