» azurerm_dev_test_linux_virtual_machine

Manages a Linux Virtual Machine within a Dev Test Lab.

» Example Usage

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

resource "azurerm_dev_test_lab" "test" {
  name                = "example-devtestlab"
  location            = "${azurerm_resource_group.test.location}"
  resource_group_name = "${azurerm_resource_group.test.name}"

  tags = {
    "Sydney" = "Australia"
  }
}

resource "azurerm_dev_test_virtual_network" "test" {
  name                = "example-network"
  lab_name            = "${azurerm_dev_test_lab.test.name}"
  resource_group_name = "${azurerm_resource_group.test.name}"

  subnet {
    use_public_ip_address           = "Allow"
    use_in_virtual_machine_creation = "Allow"
  }
}

resource "azurerm_dev_test_linux_virtual_machine" "test" {
  name                   = "example-vm03"
  lab_name               = "${azurerm_dev_test_lab.test.name}"
  resource_group_name    = "${azurerm_resource_group.test.name}"
  location               = "${azurerm_resource_group.test.location}"
  size                   = "Standard_DS2"
  username               = "exampleuser99"
  ssh_key                = "${file("~/.ssh/id_rsa.pub")}"
  lab_virtual_network_id = "${azurerm_dev_test_virtual_network.test.id}"
  lab_subnet_name        = "${azurerm_dev_test_virtual_network.test.subnet.0.name}"
  storage_type           = "Premium"
  notes                  = "Some notes about this Virtual Machine."

  gallery_image_reference {
    offer     = "UbuntuServer"
    publisher = "Canonical"
    sku       = "18.04-LTS"
    version   = "latest"
  }
}

» Argument Reference

The following arguments are supported:

  • name - (Required) Specifies the name of the Dev Test Machine. Changing this forces a new resource to be created.
  • lab_name - (Required) Specifies the name of the Dev Test Lab in which the Virtual Machine should be created. Changing this forces a new resource to be created.

  • resource_group_name - (Required) The name of the resource group in which the Dev Test Lab resource exists. Changing this forces a new resource to be created.

  • location - (Required) Specifies the supported Azure location where the Dev Test Lab exists. Changing this forces a new resource to be created.

  • gallery_image_reference - (Required) A gallery_image_reference block as defined below.

  • lab_subnet_name - (Required) The name of a Subnet within the Dev Test Virtual Network where this machine should exist. Changing this forces a new resource to be created.

  • lab_virtual_network_id - (Required) The ID of the Dev Test Virtual Network where this Virtual Machine should be created. Changing this forces a new resource to be created.

  • size - (Required) The Machine Size to use for this Virtual Machine, such as Standard_F2. Changing this forces a new resource to be created.

  • storage_type - (Required) The type of Storage to use on this Virtual Machine. Possible values are Standard and Premium.

  • username - (Required) The Username associated with the local administrator on this Virtual Machine. Changing this forces a new resource to be created.


  • allow_claim - (Optional) Can this Virtual Machine be claimed by users? Defaults to true.

  • disallow_public_ip_address - (Optional) Should the Virtual Machine be created without a Public IP Address? Changing this forces a new resource to be created.

  • inbound_nat_rule - (Optional) One or more inbound_nat_rule blocks as defined below. Changing this forces a new resource to be created.

  • notes - (Optional) Any notes about the Virtual Machine.

  • password - (Optional) The Password associated with the username used to login to this Virtual Machine. Changing this forces a new resource to be created.

  • ssh_key - (Optional) The SSH Key associated with the username used to login to this Virtual Machine. Changing this forces a new resource to be created.

  • tags - (Optional) A mapping of tags to assign to the resource.

A gallery_image_reference block supports the following:

  • offer - (Required) The Offer of the Gallery Image. Changing this forces a new resource to be created.

  • publisher - (Required) The Publisher of the Gallery Image. Changing this forces a new resource to be created.

  • sku - (Required) The SKU of the Gallery Image. Changing this forces a new resource to be created.

  • version - (Required) The Version of the Gallery Image. Changing this forces a new resource to be created.


A inbound_nat_rule block supports the following:

  • protocol - (Required) The Protocol used for this NAT Rule. Possible values are Tcp and Udp. Changing this forces a new resource to be created.

  • backend_port - (Required) The Backend Port associated with this NAT Rule. Changing this forces a new resource to be created.

» Attributes Reference

The following attributes are exported:

  • id - The ID of the Virtual Machine.

  • fqdn - The FQDN of the Virtual Machine.

  • inbound_nat_rule - One or more inbound_nat_rule blocks as defined below.

  • unique_identifier - The unique immutable identifier of the Virtual Machine.


A inbound_nat_rule block exports the following:

  • frontend_port - The frontend port associated with this Inbound NAT Rule.

» Import

Dev Test Linux Virtual Machines can be imported using the resource id, e.g.

terraform import azurerm_dev_test_linux_virtual_machine.machine1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.DevTestLab/labs/lab1/virtualmachines/machine1