LinuxVirtualMachine

class LinuxVirtualMachine : KotlinCustomResource

Manages a Linux Virtual Machine within a Dev Test Lab.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
import * as std from "@pulumi/std";
const example = new azure.core.ResourceGroup("example", {
name: "example-resources",
location: "West Europe",
});
const exampleLab = new azure.devtest.Lab("example", {
name: "example-devtestlab",
location: example.location,
resourceGroupName: example.name,
tags: {
Sydney: "Australia",
},
});
const exampleVirtualNetwork = new azure.devtest.VirtualNetwork("example", {
name: "example-network",
labName: exampleLab.name,
resourceGroupName: example.name,
subnet: {
usePublicIpAddress: "Allow",
useInVirtualMachineCreation: "Allow",
},
});
const exampleLinuxVirtualMachine = new azure.devtest.LinuxVirtualMachine("example", {
name: "example-vm03",
labName: exampleLab.name,
resourceGroupName: example.name,
location: example.location,
size: "Standard_DS2",
username: "exampleuser99",
sshKey: std.file({
input: "~/.ssh/id_rsa.pub",
}).then(invoke => invoke.result),
labVirtualNetworkId: exampleVirtualNetwork.id,
labSubnetName: exampleVirtualNetwork.subnet.apply(subnet => subnet.name),
storageType: "Premium",
notes: "Some notes about this Virtual Machine.",
galleryImageReference: {
publisher: "Canonical",
offer: "0001-com-ubuntu-server-jammy",
sku: "22_04-lts",
version: "latest",
},
});
import pulumi
import pulumi_azure as azure
import pulumi_std as std
example = azure.core.ResourceGroup("example",
name="example-resources",
location="West Europe")
example_lab = azure.devtest.Lab("example",
name="example-devtestlab",
location=example.location,
resource_group_name=example.name,
tags={
"Sydney": "Australia",
})
example_virtual_network = azure.devtest.VirtualNetwork("example",
name="example-network",
lab_name=example_lab.name,
resource_group_name=example.name,
subnet={
"use_public_ip_address": "Allow",
"use_in_virtual_machine_creation": "Allow",
})
example_linux_virtual_machine = azure.devtest.LinuxVirtualMachine("example",
name="example-vm03",
lab_name=example_lab.name,
resource_group_name=example.name,
location=example.location,
size="Standard_DS2",
username="exampleuser99",
ssh_key=std.file(input="~/.ssh/id_rsa.pub").result,
lab_virtual_network_id=example_virtual_network.id,
lab_subnet_name=example_virtual_network.subnet.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",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
using Std = Pulumi.Std;
return await Deployment.RunAsync(() =>
{
var example = new Azure.Core.ResourceGroup("example", new()
{
Name = "example-resources",
Location = "West Europe",
});
var exampleLab = new Azure.DevTest.Lab("example", new()
{
Name = "example-devtestlab",
Location = example.Location,
ResourceGroupName = example.Name,
Tags =
{
{ "Sydney", "Australia" },
},
});
var exampleVirtualNetwork = new Azure.DevTest.VirtualNetwork("example", new()
{
Name = "example-network",
LabName = exampleLab.Name,
ResourceGroupName = example.Name,
Subnet = new Azure.DevTest.Inputs.VirtualNetworkSubnetArgs
{
UsePublicIpAddress = "Allow",
UseInVirtualMachineCreation = "Allow",
},
});
var exampleLinuxVirtualMachine = new Azure.DevTest.LinuxVirtualMachine("example", new()
{
Name = "example-vm03",
LabName = exampleLab.Name,
ResourceGroupName = example.Name,
Location = example.Location,
Size = "Standard_DS2",
Username = "exampleuser99",
SshKey = Std.File.Invoke(new()
{
Input = "~/.ssh/id_rsa.pub",
}).Apply(invoke => invoke.Result),
LabVirtualNetworkId = exampleVirtualNetwork.Id,
LabSubnetName = exampleVirtualNetwork.Subnet.Apply(subnet => subnet.Name),
StorageType = "Premium",
Notes = "Some notes about this Virtual Machine.",
GalleryImageReference = new Azure.DevTest.Inputs.LinuxVirtualMachineGalleryImageReferenceArgs
{
Publisher = "Canonical",
Offer = "0001-com-ubuntu-server-jammy",
Sku = "22_04-lts",
Version = "latest",
},
});
});
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/devtest"
"github.com/pulumi/pulumi-std/sdk/go/std"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
Name: pulumi.String("example-resources"),
Location: pulumi.String("West Europe"),
})
if err != nil {
return err
}
exampleLab, err := devtest.NewLab(ctx, "example", &devtest.LabArgs{
Name: pulumi.String("example-devtestlab"),
Location: example.Location,
ResourceGroupName: example.Name,
Tags: pulumi.StringMap{
"Sydney": pulumi.String("Australia"),
},
})
if err != nil {
return err
}
exampleVirtualNetwork, err := devtest.NewVirtualNetwork(ctx, "example", &devtest.VirtualNetworkArgs{
Name: pulumi.String("example-network"),
LabName: exampleLab.Name,
ResourceGroupName: example.Name,
Subnet: &devtest.VirtualNetworkSubnetArgs{
UsePublicIpAddress: pulumi.String("Allow"),
UseInVirtualMachineCreation: pulumi.String("Allow"),
},
})
if err != nil {
return err
}
invokeFile, err := std.File(ctx, &std.FileArgs{
Input: "~/.ssh/id_rsa.pub",
}, nil)
if err != nil {
return err
}
_, err = devtest.NewLinuxVirtualMachine(ctx, "example", &devtest.LinuxVirtualMachineArgs{
Name: pulumi.String("example-vm03"),
LabName: exampleLab.Name,
ResourceGroupName: example.Name,
Location: example.Location,
Size: pulumi.String("Standard_DS2"),
Username: pulumi.String("exampleuser99"),
SshKey: pulumi.String(invokeFile.Result),
LabVirtualNetworkId: exampleVirtualNetwork.ID(),
LabSubnetName: pulumi.String(exampleVirtualNetwork.Subnet.ApplyT(func(subnet devtest.VirtualNetworkSubnet) (*string, error) {
return &subnet.Name, nil
}).(pulumi.StringPtrOutput)),
StorageType: pulumi.String("Premium"),
Notes: pulumi.String("Some notes about this Virtual Machine."),
GalleryImageReference: &devtest.LinuxVirtualMachineGalleryImageReferenceArgs{
Publisher: pulumi.String("Canonical"),
Offer: pulumi.String("0001-com-ubuntu-server-jammy"),
Sku: pulumi.String("22_04-lts"),
Version: pulumi.String("latest"),
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.devtest.Lab;
import com.pulumi.azure.devtest.LabArgs;
import com.pulumi.azure.devtest.VirtualNetwork;
import com.pulumi.azure.devtest.VirtualNetworkArgs;
import com.pulumi.azure.devtest.inputs.VirtualNetworkSubnetArgs;
import com.pulumi.azure.devtest.LinuxVirtualMachine;
import com.pulumi.azure.devtest.LinuxVirtualMachineArgs;
import com.pulumi.azure.devtest.inputs.LinuxVirtualMachineGalleryImageReferenceArgs;
import com.pulumi.std.StdFunctions;
import com.pulumi.std.inputs.FileArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new ResourceGroup("example", ResourceGroupArgs.builder()
.name("example-resources")
.location("West Europe")
.build());
var exampleLab = new Lab("exampleLab", LabArgs.builder()
.name("example-devtestlab")
.location(example.location())
.resourceGroupName(example.name())
.tags(Map.of("Sydney", "Australia"))
.build());
var exampleVirtualNetwork = new VirtualNetwork("exampleVirtualNetwork", VirtualNetworkArgs.builder()
.name("example-network")
.labName(exampleLab.name())
.resourceGroupName(example.name())
.subnet(VirtualNetworkSubnetArgs.builder()
.usePublicIpAddress("Allow")
.useInVirtualMachineCreation("Allow")
.build())
.build());
var exampleLinuxVirtualMachine = new LinuxVirtualMachine("exampleLinuxVirtualMachine", LinuxVirtualMachineArgs.builder()
.name("example-vm03")
.labName(exampleLab.name())
.resourceGroupName(example.name())
.location(example.location())
.size("Standard_DS2")
.username("exampleuser99")
.sshKey(StdFunctions.file(FileArgs.builder()
.input("~/.ssh/id_rsa.pub")
.build()).result())
.labVirtualNetworkId(exampleVirtualNetwork.id())
.labSubnetName(exampleVirtualNetwork.subnet().applyValue(_subnet -> _subnet.name()))
.storageType("Premium")
.notes("Some notes about this Virtual Machine.")
.galleryImageReference(LinuxVirtualMachineGalleryImageReferenceArgs.builder()
.publisher("Canonical")
.offer("0001-com-ubuntu-server-jammy")
.sku("22_04-lts")
.version("latest")
.build())
.build());
}
}
resources:
example:
type: azure:core:ResourceGroup
properties:
name: example-resources
location: West Europe
exampleLab:
type: azure:devtest:Lab
name: example
properties:
name: example-devtestlab
location: ${example.location}
resourceGroupName: ${example.name}
tags:
Sydney: Australia
exampleVirtualNetwork:
type: azure:devtest:VirtualNetwork
name: example
properties:
name: example-network
labName: ${exampleLab.name}
resourceGroupName: ${example.name}
subnet:
usePublicIpAddress: Allow
useInVirtualMachineCreation: Allow
exampleLinuxVirtualMachine:
type: azure:devtest:LinuxVirtualMachine
name: example
properties:
name: example-vm03
labName: ${exampleLab.name}
resourceGroupName: ${example.name}
location: ${example.location}
size: Standard_DS2
username: exampleuser99
sshKey:
fn::invoke:
function: std:file
arguments:
input: ~/.ssh/id_rsa.pub
return: result
labVirtualNetworkId: ${exampleVirtualNetwork.id}
labSubnetName: ${exampleVirtualNetwork.subnet.name}
storageType: Premium
notes: Some notes about this Virtual Machine.
galleryImageReference:
publisher: Canonical
offer: 0001-com-ubuntu-server-jammy
sku: 22_04-lts
version: latest

API Providers

This resource uses the following Azure API Providers:

  • Microsoft.DevTestLab: 2018-09-15

Import

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

$ pulumi import azure:devtest/linuxVirtualMachine:LinuxVirtualMachine machine1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.DevTestLab/labs/lab1/virtualMachines/machine1

Properties

Link copied to clipboard
val allowClaim: Output<Boolean>?

Can this Virtual Machine be claimed by users? Defaults to true.

Link copied to clipboard

Should the Virtual Machine be created without a Public IP Address? Changing this forces a new resource to be created.

Link copied to clipboard
val fqdn: Output<String>

The FQDN of the Virtual Machine.

Link copied to clipboard

A gallery_image_reference block as defined below.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard

One or more inbound_nat_rule blocks as defined below. Changing this forces a new resource to be created.

Link copied to clipboard
val labName: Output<String>

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.

Link copied to clipboard
val labSubnetName: Output<String>

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.

Link copied to clipboard

The ID of the Dev Test Virtual Network where this Virtual Machine should be created. Changing this forces a new resource to be created.

Link copied to clipboard
val location: Output<String>

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

Link copied to clipboard
val name: Output<String>

Specifies the name of the Dev Test Machine. Changing this forces a new resource to be created.

Link copied to clipboard
val notes: Output<String>?

Any notes about the Virtual Machine.

Link copied to clipboard
val password: Output<String>?

The Password associated with the username used to login to this Virtual Machine. Changing this forces a new resource to be created.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The name of the resource group in which the Dev Test Lab resource exists. Changing this forces a new resource to be created.

Link copied to clipboard
val size: Output<String>

The Machine Size to use for this Virtual Machine, such as Standard_F2. Changing this forces a new resource to be created.

Link copied to clipboard
val sshKey: Output<String>?

The SSH Key associated with the username used to login to this Virtual Machine. Changing this forces a new resource to be created.

Link copied to clipboard
val storageType: Output<String>

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.

Link copied to clipboard
val tags: Output<Map<String, String>>?

A mapping of tags to assign to the resource.

Link copied to clipboard

The unique immutable identifier of the Virtual Machine.

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val username: Output<String>

The Username associated with the local administrator on this Virtual Machine. Changing this forces a new resource to be created.