Manages a Linux Virtual Machine within a Dev Test Lab.
resource "azurerm_resource_group" "example" {
name = "example-resources"
location = "West Europe"
}
resource "azurerm_dev_test_lab" "example" {
name = "example-devtestlab"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
tags = {
"Sydney" = "Australia"
}
}
resource "azurerm_dev_test_virtual_network" "example" {
name = "example-network"
lab_name = azurerm_dev_test_lab.example.name
resource_group_name = azurerm_resource_group.example.name
subnet {
use_public_ip_address = "Allow"
use_in_virtual_machine_creation = "Allow"
}
}
resource "azurerm_dev_test_linux_virtual_machine" "example" {
name = "example-vm03"
lab_name = azurerm_dev_test_lab.example.name
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
size = "Standard_DS2"
username = "exampleuser99"
ssh_key = file("~/.ssh/id_rsa.pub")
lab_virtual_network_id = azurerm_dev_test_virtual_network.example.id
lab_subnet_name = azurerm_dev_test_virtual_network.example.subnet[0].name
storage_type = "Premium"
notes = "Some notes about this Virtual Machine."
gallery_image_reference {
publisher = "Canonical"
offer = "0001-com-ubuntu-server-jammy"
sku = "22_04-lts"
version = "latest"
}
}
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
. Changing this forces a new resource to be created.
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
.
backend_port
- (Required) The Backend Port associated with this NAT Rule. Changing this forces a new resource to be created.
In addition to the Arguments listed above - 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.The timeouts
block allows you to specify timeouts for certain actions:
create
- (Defaults to 30 minutes) Used when creating the DevTest Linux Virtual Machine.update
- (Defaults to 30 minutes) Used when updating the DevTest Linux Virtual Machine.read
- (Defaults to 5 minutes) Used when retrieving the DevTest Linux Virtual Machine.delete
- (Defaults to 30 minutes) Used when deleting the DevTest Linux Virtual Machine.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