1. Packages
  2. Proxmox Virtual Environment (Proxmox VE)
  3. API Docs
  4. VM
  5. getVirtualMachines
Proxmox Virtual Environment (Proxmox VE) v7.0.0 published on Tuesday, Apr 1, 2025 by Daniel Muehlbachler-Pietrzykowski

proxmoxve.VM.getVirtualMachines

Explore with Pulumi AI

Proxmox Virtual Environment (Proxmox VE) v7.0.0 published on Tuesday, Apr 1, 2025 by Daniel Muehlbachler-Pietrzykowski

Retrieves information about all VMs in the Proxmox cluster.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as proxmoxve from "@pulumi/proxmoxve";

const ubuntuVms = proxmoxve.VM.getVirtualMachines({
    tags: ["ubuntu"],
});
const ubuntuTemplates = proxmoxve.VM.getVirtualMachines({
    filters: [
        {
            name: "template",
            values: ["true"],
        },
        {
            name: "status",
            values: ["stopped"],
        },
        {
            name: "name",
            regex: true,
            values: ["^ubuntu-20.*$"],
        },
        {
            name: "node_name",
            regex: true,
            values: [
                "node_us_[1-3]",
                "node_eu_[1-3]",
            ],
        },
    ],
    tags: [
        "template",
        "latest",
    ],
});
Copy
import pulumi
import pulumi_proxmoxve as proxmoxve

ubuntu_vms = proxmoxve.VM.get_virtual_machines(tags=["ubuntu"])
ubuntu_templates = proxmoxve.VM.get_virtual_machines(filters=[
        {
            "name": "template",
            "values": ["true"],
        },
        {
            "name": "status",
            "values": ["stopped"],
        },
        {
            "name": "name",
            "regex": True,
            "values": ["^ubuntu-20.*$"],
        },
        {
            "name": "node_name",
            "regex": True,
            "values": [
                "node_us_[1-3]",
                "node_eu_[1-3]",
            ],
        },
    ],
    tags=[
        "template",
        "latest",
    ])
Copy
package main

import (
	"github.com/muhlba91/pulumi-proxmoxve/sdk/v6/go/proxmoxve/vm"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := vm.GetVirtualMachines(ctx, &vm.GetVirtualMachinesArgs{
			Tags: []string{
				"ubuntu",
			},
		}, nil)
		if err != nil {
			return err
		}
		_, err = vm.GetVirtualMachines(ctx, &vm.GetVirtualMachinesArgs{
			Filters: []vm.GetVirtualMachinesFilter{
				{
					Name: "template",
					Values: []string{
						"true",
					},
				},
				{
					Name: "status",
					Values: []string{
						"stopped",
					},
				},
				{
					Name:  "name",
					Regex: pulumi.BoolRef(true),
					Values: []string{
						"^ubuntu-20.*$",
					},
				},
				{
					Name:  "node_name",
					Regex: pulumi.BoolRef(true),
					Values: []string{
						"node_us_[1-3]",
						"node_eu_[1-3]",
					},
				},
			},
			Tags: []string{
				"template",
				"latest",
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using ProxmoxVE = Pulumi.ProxmoxVE;

return await Deployment.RunAsync(() => 
{
    var ubuntuVms = ProxmoxVE.VM.GetVirtualMachines.Invoke(new()
    {
        Tags = new[]
        {
            "ubuntu",
        },
    });

    var ubuntuTemplates = ProxmoxVE.VM.GetVirtualMachines.Invoke(new()
    {
        Filters = new[]
        {
            new ProxmoxVE.VM.Inputs.GetVirtualMachinesFilterInputArgs
            {
                Name = "template",
                Values = new[]
                {
                    "true",
                },
            },
            new ProxmoxVE.VM.Inputs.GetVirtualMachinesFilterInputArgs
            {
                Name = "status",
                Values = new[]
                {
                    "stopped",
                },
            },
            new ProxmoxVE.VM.Inputs.GetVirtualMachinesFilterInputArgs
            {
                Name = "name",
                Regex = true,
                Values = new[]
                {
                    "^ubuntu-20.*$",
                },
            },
            new ProxmoxVE.VM.Inputs.GetVirtualMachinesFilterInputArgs
            {
                Name = "node_name",
                Regex = true,
                Values = new[]
                {
                    "node_us_[1-3]",
                    "node_eu_[1-3]",
                },
            },
        },
        Tags = new[]
        {
            "template",
            "latest",
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.proxmoxve.VM.VMFunctions;
import com.pulumi.proxmoxve.VM.inputs.GetVirtualMachinesArgs;
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) {
        final var ubuntuVms = VMFunctions.getVirtualMachines(GetVirtualMachinesArgs.builder()
            .tags("ubuntu")
            .build());

        final var ubuntuTemplates = VMFunctions.getVirtualMachines(GetVirtualMachinesArgs.builder()
            .filters(            
                GetVirtualMachinesFilterArgs.builder()
                    .name("template")
                    .values(true)
                    .build(),
                GetVirtualMachinesFilterArgs.builder()
                    .name("status")
                    .values("stopped")
                    .build(),
                GetVirtualMachinesFilterArgs.builder()
                    .name("name")
                    .regex(true)
                    .values("^ubuntu-20.*$")
                    .build(),
                GetVirtualMachinesFilterArgs.builder()
                    .name("node_name")
                    .regex(true)
                    .values(                    
                        "node_us_[1-3]",
                        "node_eu_[1-3]")
                    .build())
            .tags(            
                "template",
                "latest")
            .build());

    }
}
Copy
variables:
  ubuntuVms:
    fn::invoke:
      function: proxmoxve:VM:getVirtualMachines
      arguments:
        tags:
          - ubuntu
  ubuntuTemplates:
    fn::invoke:
      function: proxmoxve:VM:getVirtualMachines
      arguments:
        filters:
          - name: template
            values:
              - true
          - name: status
            values:
              - stopped
          - name: name
            regex: true
            values:
              - ^ubuntu-20.*$
          - name: node_name
            regex: true
            values:
              - node_us_[1-3]
              - node_eu_[1-3]
        tags:
          - template
          - latest
Copy

Using getVirtualMachines

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getVirtualMachines(args: GetVirtualMachinesArgs, opts?: InvokeOptions): Promise<GetVirtualMachinesResult>
function getVirtualMachinesOutput(args: GetVirtualMachinesOutputArgs, opts?: InvokeOptions): Output<GetVirtualMachinesResult>
Copy
def get_virtual_machines(filters: Optional[Sequence[_vm.GetVirtualMachinesFilter]] = None,
                         node_name: Optional[str] = None,
                         tags: Optional[Sequence[str]] = None,
                         opts: Optional[InvokeOptions] = None) -> GetVirtualMachinesResult
def get_virtual_machines_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[_vm.GetVirtualMachinesFilterArgs]]]] = None,
                         node_name: Optional[pulumi.Input[str]] = None,
                         tags: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                         opts: Optional[InvokeOptions] = None) -> Output[GetVirtualMachinesResult]
Copy
func GetVirtualMachines(ctx *Context, args *GetVirtualMachinesArgs, opts ...InvokeOption) (*GetVirtualMachinesResult, error)
func GetVirtualMachinesOutput(ctx *Context, args *GetVirtualMachinesOutputArgs, opts ...InvokeOption) GetVirtualMachinesResultOutput
Copy

> Note: This function is named GetVirtualMachines in the Go SDK.

public static class GetVirtualMachines 
{
    public static Task<GetVirtualMachinesResult> InvokeAsync(GetVirtualMachinesArgs args, InvokeOptions? opts = null)
    public static Output<GetVirtualMachinesResult> Invoke(GetVirtualMachinesInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetVirtualMachinesResult> getVirtualMachines(GetVirtualMachinesArgs args, InvokeOptions options)
public static Output<GetVirtualMachinesResult> getVirtualMachines(GetVirtualMachinesArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: proxmoxve:VM/getVirtualMachines:getVirtualMachines
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Filters List<Pulumi.ProxmoxVE.VM.Inputs.GetVirtualMachinesFilter>
Filter blocks. The VM must satisfy all filter blocks to be included in the result.
NodeName string
The node name. All cluster nodes will be queried in case this is omitted
Tags List<string>
A list of tags to filter the VMs. The VM must have all the tags to be included in the result.
Filters []GetVirtualMachinesFilter
Filter blocks. The VM must satisfy all filter blocks to be included in the result.
NodeName string
The node name. All cluster nodes will be queried in case this is omitted
Tags []string
A list of tags to filter the VMs. The VM must have all the tags to be included in the result.
filters List<GetVirtualMachinesFilter>
Filter blocks. The VM must satisfy all filter blocks to be included in the result.
nodeName String
The node name. All cluster nodes will be queried in case this is omitted
tags List<String>
A list of tags to filter the VMs. The VM must have all the tags to be included in the result.
filters GetVirtualMachinesFilter[]
Filter blocks. The VM must satisfy all filter blocks to be included in the result.
nodeName string
The node name. All cluster nodes will be queried in case this is omitted
tags string[]
A list of tags to filter the VMs. The VM must have all the tags to be included in the result.
filters Sequence[vm.GetVirtualMachinesFilter]
Filter blocks. The VM must satisfy all filter blocks to be included in the result.
node_name str
The node name. All cluster nodes will be queried in case this is omitted
tags Sequence[str]
A list of tags to filter the VMs. The VM must have all the tags to be included in the result.
filters List<Property Map>
Filter blocks. The VM must satisfy all filter blocks to be included in the result.
nodeName String
The node name. All cluster nodes will be queried in case this is omitted
tags List<String>
A list of tags to filter the VMs. The VM must have all the tags to be included in the result.

getVirtualMachines Result

The following output properties are available:

Id string
The provider-assigned unique ID for this managed resource.
Vms List<Pulumi.ProxmoxVE.VM.Outputs.GetVirtualMachinesVm>
The VMs list.
Filters List<Pulumi.ProxmoxVE.VM.Outputs.GetVirtualMachinesFilter>
NodeName string
The node name.
Tags List<string>
A list of tags of the VM.
Id string
The provider-assigned unique ID for this managed resource.
Vms []GetVirtualMachinesVm
The VMs list.
Filters []GetVirtualMachinesFilter
NodeName string
The node name.
Tags []string
A list of tags of the VM.
id String
The provider-assigned unique ID for this managed resource.
vms List<GetVirtualMachinesVm>
The VMs list.
filters List<GetVirtualMachinesFilter>
nodeName String
The node name.
tags List<String>
A list of tags of the VM.
id string
The provider-assigned unique ID for this managed resource.
vms GetVirtualMachinesVm[]
The VMs list.
filters GetVirtualMachinesFilter[]
nodeName string
The node name.
tags string[]
A list of tags of the VM.
id str
The provider-assigned unique ID for this managed resource.
vms Sequence[vm.GetVirtualMachinesVm]
The VMs list.
filters Sequence[vm.GetVirtualMachinesFilter]
node_name str
The node name.
tags Sequence[str]
A list of tags of the VM.
id String
The provider-assigned unique ID for this managed resource.
vms List<Property Map>
The VMs list.
filters List<Property Map>
nodeName String
The node name.
tags List<String>
A list of tags of the VM.

Supporting Types

GetVirtualMachinesFilter

Name This property is required. string
Name of the VM attribute to filter on. One of [name, template, status, node_name]
Values This property is required. List<string>
List of values to pass the filter. VM's attribute should match at least one value in the list.
Regex bool
Treat values as regex patterns
Name This property is required. string
Name of the VM attribute to filter on. One of [name, template, status, node_name]
Values This property is required. []string
List of values to pass the filter. VM's attribute should match at least one value in the list.
Regex bool
Treat values as regex patterns
name This property is required. String
Name of the VM attribute to filter on. One of [name, template, status, node_name]
values This property is required. List<String>
List of values to pass the filter. VM's attribute should match at least one value in the list.
regex Boolean
Treat values as regex patterns
name This property is required. string
Name of the VM attribute to filter on. One of [name, template, status, node_name]
values This property is required. string[]
List of values to pass the filter. VM's attribute should match at least one value in the list.
regex boolean
Treat values as regex patterns
name This property is required. str
Name of the VM attribute to filter on. One of [name, template, status, node_name]
values This property is required. Sequence[str]
List of values to pass the filter. VM's attribute should match at least one value in the list.
regex bool
Treat values as regex patterns
name This property is required. String
Name of the VM attribute to filter on. One of [name, template, status, node_name]
values This property is required. List<String>
List of values to pass the filter. VM's attribute should match at least one value in the list.
regex Boolean
Treat values as regex patterns

GetVirtualMachinesVm

Name This property is required. string
The virtual machine name.
NodeName This property is required. string
The node name. All cluster nodes will be queried in case this is omitted
Tags This property is required. List<string>
A list of tags to filter the VMs. The VM must have all the tags to be included in the result.
VmId This property is required. int
The VM identifier.
Status string
Status of the VM
Template bool
Is VM a template (true) or a regular VM (false)
Name This property is required. string
The virtual machine name.
NodeName This property is required. string
The node name. All cluster nodes will be queried in case this is omitted
Tags This property is required. []string
A list of tags to filter the VMs. The VM must have all the tags to be included in the result.
VmId This property is required. int
The VM identifier.
Status string
Status of the VM
Template bool
Is VM a template (true) or a regular VM (false)
name This property is required. String
The virtual machine name.
nodeName This property is required. String
The node name. All cluster nodes will be queried in case this is omitted
tags This property is required. List<String>
A list of tags to filter the VMs. The VM must have all the tags to be included in the result.
vmId This property is required. Integer
The VM identifier.
status String
Status of the VM
template Boolean
Is VM a template (true) or a regular VM (false)
name This property is required. string
The virtual machine name.
nodeName This property is required. string
The node name. All cluster nodes will be queried in case this is omitted
tags This property is required. string[]
A list of tags to filter the VMs. The VM must have all the tags to be included in the result.
vmId This property is required. number
The VM identifier.
status string
Status of the VM
template boolean
Is VM a template (true) or a regular VM (false)
name This property is required. str
The virtual machine name.
node_name This property is required. str
The node name. All cluster nodes will be queried in case this is omitted
tags This property is required. Sequence[str]
A list of tags to filter the VMs. The VM must have all the tags to be included in the result.
vm_id This property is required. int
The VM identifier.
status str
Status of the VM
template bool
Is VM a template (true) or a regular VM (false)
name This property is required. String
The virtual machine name.
nodeName This property is required. String
The node name. All cluster nodes will be queried in case this is omitted
tags This property is required. List<String>
A list of tags to filter the VMs. The VM must have all the tags to be included in the result.
vmId This property is required. Number
The VM identifier.
status String
Status of the VM
template Boolean
Is VM a template (true) or a regular VM (false)

Package Details

Repository
proxmoxve muhlba91/pulumi-proxmoxve
License
Apache-2.0
Notes
This Pulumi package is based on the proxmox Terraform Provider.
Proxmox Virtual Environment (Proxmox VE) v7.0.0 published on Tuesday, Apr 1, 2025 by Daniel Muehlbachler-Pietrzykowski