1. Packages
  2. Nsxt Provider
  3. API Docs
  4. getPolicyVm
nsxt 3.8.1 published on Wednesday, Apr 30, 2025 by vmware

nsxt.getPolicyVm

Explore with Pulumi AI

nsxt logo
nsxt 3.8.1 published on Wednesday, Apr 30, 2025 by vmware

    This data source provides information about Policy based Virtual Machine (VM) listed in NSX inventory, and allows look-up of the VM by display_name or the BIOS, external or instance ID exposed on the VM resource.

    This data source is applicable to NSX Policy Manager and VMC.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as nsxt from "@pulumi/nsxt";
    
    const nsxtVm1 = nsxt.getPolicyVm({
        displayName: "nsxt-virtualmachine1",
    });
    
    import pulumi
    import pulumi_nsxt as nsxt
    
    nsxt_vm1 = nsxt.get_policy_vm(display_name="nsxt-virtualmachine1")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/nsxt/v3/nsxt"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := nsxt.GetPolicyVm(ctx, &nsxt.GetPolicyVmArgs{
    			DisplayName: pulumi.StringRef("nsxt-virtualmachine1"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Nsxt = Pulumi.Nsxt;
    
    return await Deployment.RunAsync(() => 
    {
        var nsxtVm1 = Nsxt.GetPolicyVm.Invoke(new()
        {
            DisplayName = "nsxt-virtualmachine1",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.nsxt.NsxtFunctions;
    import com.pulumi.nsxt.inputs.GetPolicyVmArgs;
    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 nsxtVm1 = NsxtFunctions.getPolicyVm(GetPolicyVmArgs.builder()
                .displayName("nsxt-virtualmachine1")
                .build());
    
        }
    }
    
    variables:
      nsxtVm1:
        fn::invoke:
          function: nsxt:getPolicyVm
          arguments:
            displayName: nsxt-virtualmachine1
    

    Multi-Tenancy

    import * as pulumi from "@pulumi/pulumi";
    import * as nsxt from "@pulumi/nsxt";
    
    const demoproj = nsxt.getPolicyProject({
        displayName: "demoproj",
    });
    const nsxtVm1 = demoproj.then(demoproj => nsxt.getPolicyVm({
        context: {
            projectId: demoproj.id,
        },
        displayName: "nsxt-virtualmachine1",
    }));
    
    import pulumi
    import pulumi_nsxt as nsxt
    
    demoproj = nsxt.get_policy_project(display_name="demoproj")
    nsxt_vm1 = nsxt.get_policy_vm(context={
            "project_id": demoproj.id,
        },
        display_name="nsxt-virtualmachine1")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/nsxt/v3/nsxt"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		demoproj, err := nsxt.LookupPolicyProject(ctx, &nsxt.LookupPolicyProjectArgs{
    			DisplayName: pulumi.StringRef("demoproj"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = nsxt.GetPolicyVm(ctx, &nsxt.GetPolicyVmArgs{
    			Context: nsxt.GetPolicyVmContext{
    				ProjectId: demoproj.Id,
    			},
    			DisplayName: pulumi.StringRef("nsxt-virtualmachine1"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Nsxt = Pulumi.Nsxt;
    
    return await Deployment.RunAsync(() => 
    {
        var demoproj = Nsxt.GetPolicyProject.Invoke(new()
        {
            DisplayName = "demoproj",
        });
    
        var nsxtVm1 = Nsxt.GetPolicyVm.Invoke(new()
        {
            Context = new Nsxt.Inputs.GetPolicyVmContextInputArgs
            {
                ProjectId = demoproj.Apply(getPolicyProjectResult => getPolicyProjectResult.Id),
            },
            DisplayName = "nsxt-virtualmachine1",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.nsxt.NsxtFunctions;
    import com.pulumi.nsxt.inputs.GetPolicyProjectArgs;
    import com.pulumi.nsxt.inputs.GetPolicyVmArgs;
    import com.pulumi.nsxt.inputs.GetPolicyVmContextArgs;
    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 demoproj = NsxtFunctions.getPolicyProject(GetPolicyProjectArgs.builder()
                .displayName("demoproj")
                .build());
    
            final var nsxtVm1 = NsxtFunctions.getPolicyVm(GetPolicyVmArgs.builder()
                .context(GetPolicyVmContextArgs.builder()
                    .projectId(demoproj.applyValue(getPolicyProjectResult -> getPolicyProjectResult.id()))
                    .build())
                .displayName("nsxt-virtualmachine1")
                .build());
    
        }
    }
    
    variables:
      demoproj:
        fn::invoke:
          function: nsxt:getPolicyProject
          arguments:
            displayName: demoproj
      nsxtVm1:
        fn::invoke:
          function: nsxt:getPolicyVm
          arguments:
            context:
              projectId: ${demoproj.id}
            displayName: nsxt-virtualmachine1
    

    Using getPolicyVm

    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 getPolicyVm(args: GetPolicyVmArgs, opts?: InvokeOptions): Promise<GetPolicyVmResult>
    function getPolicyVmOutput(args: GetPolicyVmOutputArgs, opts?: InvokeOptions): Output<GetPolicyVmResult>
    def get_policy_vm(bios_id: Optional[str] = None,
                      context: Optional[GetPolicyVmContext] = None,
                      description: Optional[str] = None,
                      display_name: Optional[str] = None,
                      external_id: Optional[str] = None,
                      id: Optional[str] = None,
                      instance_id: Optional[str] = None,
                      tags: Optional[Sequence[GetPolicyVmTag]] = None,
                      opts: Optional[InvokeOptions] = None) -> GetPolicyVmResult
    def get_policy_vm_output(bios_id: Optional[pulumi.Input[str]] = None,
                      context: Optional[pulumi.Input[GetPolicyVmContextArgs]] = None,
                      description: Optional[pulumi.Input[str]] = None,
                      display_name: Optional[pulumi.Input[str]] = None,
                      external_id: Optional[pulumi.Input[str]] = None,
                      id: Optional[pulumi.Input[str]] = None,
                      instance_id: Optional[pulumi.Input[str]] = None,
                      tags: Optional[pulumi.Input[Sequence[pulumi.Input[GetPolicyVmTagArgs]]]] = None,
                      opts: Optional[InvokeOptions] = None) -> Output[GetPolicyVmResult]
    func GetPolicyVm(ctx *Context, args *GetPolicyVmArgs, opts ...InvokeOption) (*GetPolicyVmResult, error)
    func GetPolicyVmOutput(ctx *Context, args *GetPolicyVmOutputArgs, opts ...InvokeOption) GetPolicyVmResultOutput

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

    public static class GetPolicyVm 
    {
        public static Task<GetPolicyVmResult> InvokeAsync(GetPolicyVmArgs args, InvokeOptions? opts = null)
        public static Output<GetPolicyVmResult> Invoke(GetPolicyVmInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetPolicyVmResult> getPolicyVm(GetPolicyVmArgs args, InvokeOptions options)
    public static Output<GetPolicyVmResult> getPolicyVm(GetPolicyVmArgs args, InvokeOptions options)
    
    fn::invoke:
      function: nsxt:index/getPolicyVm:getPolicyVm
      arguments:
        # arguments dictionary

    The following arguments are supported:

    BiosId string
    The BIOS UUID of the Virtual Machine.
    Context GetPolicyVmContext
    The context which the object belongs to
    Description string
    The description of the Virtual Machine.
    DisplayName string
    The Display Name prefix of the Virtual Machine to retrieve.
    ExternalId string
    The external ID of the Virtual Machine.
    Id string
    InstanceId string
    The instance UUID of the Virtual Machine.
    Tags List<GetPolicyVmTag>
    A list of scope + tag pairs associated with this Virtual Machine.
    BiosId string
    The BIOS UUID of the Virtual Machine.
    Context GetPolicyVmContext
    The context which the object belongs to
    Description string
    The description of the Virtual Machine.
    DisplayName string
    The Display Name prefix of the Virtual Machine to retrieve.
    ExternalId string
    The external ID of the Virtual Machine.
    Id string
    InstanceId string
    The instance UUID of the Virtual Machine.
    Tags []GetPolicyVmTag
    A list of scope + tag pairs associated with this Virtual Machine.
    biosId String
    The BIOS UUID of the Virtual Machine.
    context GetPolicyVmContext
    The context which the object belongs to
    description String
    The description of the Virtual Machine.
    displayName String
    The Display Name prefix of the Virtual Machine to retrieve.
    externalId String
    The external ID of the Virtual Machine.
    id String
    instanceId String
    The instance UUID of the Virtual Machine.
    tags List<GetPolicyVmTag>
    A list of scope + tag pairs associated with this Virtual Machine.
    biosId string
    The BIOS UUID of the Virtual Machine.
    context GetPolicyVmContext
    The context which the object belongs to
    description string
    The description of the Virtual Machine.
    displayName string
    The Display Name prefix of the Virtual Machine to retrieve.
    externalId string
    The external ID of the Virtual Machine.
    id string
    instanceId string
    The instance UUID of the Virtual Machine.
    tags GetPolicyVmTag[]
    A list of scope + tag pairs associated with this Virtual Machine.
    bios_id str
    The BIOS UUID of the Virtual Machine.
    context GetPolicyVmContext
    The context which the object belongs to
    description str
    The description of the Virtual Machine.
    display_name str
    The Display Name prefix of the Virtual Machine to retrieve.
    external_id str
    The external ID of the Virtual Machine.
    id str
    instance_id str
    The instance UUID of the Virtual Machine.
    tags Sequence[GetPolicyVmTag]
    A list of scope + tag pairs associated with this Virtual Machine.
    biosId String
    The BIOS UUID of the Virtual Machine.
    context Property Map
    The context which the object belongs to
    description String
    The description of the Virtual Machine.
    displayName String
    The Display Name prefix of the Virtual Machine to retrieve.
    externalId String
    The external ID of the Virtual Machine.
    id String
    instanceId String
    The instance UUID of the Virtual Machine.
    tags List<Property Map>
    A list of scope + tag pairs associated with this Virtual Machine.

    getPolicyVm Result

    The following output properties are available:

    BiosId string
    Description string
    The description of the Virtual Machine.
    DisplayName string
    ExternalId string
    Id string
    InstanceId string
    Context GetPolicyVmContext
    Tags List<GetPolicyVmTag>
    A list of scope + tag pairs associated with this Virtual Machine.
    BiosId string
    Description string
    The description of the Virtual Machine.
    DisplayName string
    ExternalId string
    Id string
    InstanceId string
    Context GetPolicyVmContext
    Tags []GetPolicyVmTag
    A list of scope + tag pairs associated with this Virtual Machine.
    biosId String
    description String
    The description of the Virtual Machine.
    displayName String
    externalId String
    id String
    instanceId String
    context GetPolicyVmContext
    tags List<GetPolicyVmTag>
    A list of scope + tag pairs associated with this Virtual Machine.
    biosId string
    description string
    The description of the Virtual Machine.
    displayName string
    externalId string
    id string
    instanceId string
    context GetPolicyVmContext
    tags GetPolicyVmTag[]
    A list of scope + tag pairs associated with this Virtual Machine.
    bios_id str
    description str
    The description of the Virtual Machine.
    display_name str
    external_id str
    id str
    instance_id str
    context GetPolicyVmContext
    tags Sequence[GetPolicyVmTag]
    A list of scope + tag pairs associated with this Virtual Machine.
    biosId String
    description String
    The description of the Virtual Machine.
    displayName String
    externalId String
    id String
    instanceId String
    context Property Map
    tags List<Property Map>
    A list of scope + tag pairs associated with this Virtual Machine.

    Supporting Types

    GetPolicyVmContext

    ProjectId string
    The ID of the project which the object belongs to
    ProjectId string
    The ID of the project which the object belongs to
    projectId String
    The ID of the project which the object belongs to
    projectId string
    The ID of the project which the object belongs to
    project_id str
    The ID of the project which the object belongs to
    projectId String
    The ID of the project which the object belongs to

    GetPolicyVmTag

    Scope string
    Tag string
    A list of scope + tag pairs associated with this Virtual Machine.
    Scope string
    Tag string
    A list of scope + tag pairs associated with this Virtual Machine.
    scope String
    tag String
    A list of scope + tag pairs associated with this Virtual Machine.
    scope string
    tag string
    A list of scope + tag pairs associated with this Virtual Machine.
    scope str
    tag str
    A list of scope + tag pairs associated with this Virtual Machine.
    scope String
    tag String
    A list of scope + tag pairs associated with this Virtual Machine.

    Package Details

    Repository
    nsxt vmware/terraform-provider-nsxt
    License
    Notes
    This Pulumi package is based on the nsxt Terraform Provider.
    nsxt logo
    nsxt 3.8.1 published on Wednesday, Apr 30, 2025 by vmware