nsxt 3.8.1 published on Wednesday, Apr 30, 2025 by vmware
nsxt.getPolicyVm
Explore with Pulumi AI
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:
- Bios
Id string - The BIOS UUID of the Virtual Machine.
- Context
Get
Policy Vm Context - The context which the object belongs to
- Description string
- The description of the Virtual Machine.
- Display
Name string - The Display Name prefix of the Virtual Machine to retrieve.
- External
Id string - The external ID of the Virtual Machine.
- Id string
- Instance
Id string - The instance UUID of the Virtual Machine.
- List<Get
Policy Vm Tag> - A list of scope + tag pairs associated with this Virtual Machine.
- Bios
Id string - The BIOS UUID of the Virtual Machine.
- Context
Get
Policy Vm Context - The context which the object belongs to
- Description string
- The description of the Virtual Machine.
- Display
Name string - The Display Name prefix of the Virtual Machine to retrieve.
- External
Id string - The external ID of the Virtual Machine.
- Id string
- Instance
Id string - The instance UUID of the Virtual Machine.
- []Get
Policy Vm Tag - A list of scope + tag pairs associated with this Virtual Machine.
- bios
Id String - The BIOS UUID of the Virtual Machine.
- context
Get
Policy Vm Context - The context which the object belongs to
- description String
- The description of the Virtual Machine.
- display
Name String - The Display Name prefix of the Virtual Machine to retrieve.
- external
Id String - The external ID of the Virtual Machine.
- id String
- instance
Id String - The instance UUID of the Virtual Machine.
- List<Get
Policy Vm Tag> - A list of scope + tag pairs associated with this Virtual Machine.
- bios
Id string - The BIOS UUID of the Virtual Machine.
- context
Get
Policy Vm Context - The context which the object belongs to
- description string
- The description of the Virtual Machine.
- display
Name string - The Display Name prefix of the Virtual Machine to retrieve.
- external
Id string - The external ID of the Virtual Machine.
- id string
- instance
Id string - The instance UUID of the Virtual Machine.
- Get
Policy Vm Tag[] - A list of scope + tag pairs associated with this Virtual Machine.
- bios_
id str - The BIOS UUID of the Virtual Machine.
- context
Get
Policy Vm Context - 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.
- Sequence[Get
Policy Vm Tag] - A list of scope + tag pairs associated with this Virtual Machine.
- bios
Id 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.
- display
Name String - The Display Name prefix of the Virtual Machine to retrieve.
- external
Id String - The external ID of the Virtual Machine.
- id String
- instance
Id String - The instance UUID of the Virtual Machine.
- List<Property Map>
- A list of scope + tag pairs associated with this Virtual Machine.
getPolicyVm Result
The following output properties are available:
- Bios
Id string - Description string
- The description of the Virtual Machine.
- Display
Name string - External
Id string - Id string
- Instance
Id string - Context
Get
Policy Vm Context - List<Get
Policy Vm Tag> - A list of scope + tag pairs associated with this Virtual Machine.
- Bios
Id string - Description string
- The description of the Virtual Machine.
- Display
Name string - External
Id string - Id string
- Instance
Id string - Context
Get
Policy Vm Context - []Get
Policy Vm Tag - A list of scope + tag pairs associated with this Virtual Machine.
- bios
Id String - description String
- The description of the Virtual Machine.
- display
Name String - external
Id String - id String
- instance
Id String - context
Get
Policy Vm Context - List<Get
Policy Vm Tag> - A list of scope + tag pairs associated with this Virtual Machine.
- bios
Id string - description string
- The description of the Virtual Machine.
- display
Name string - external
Id string - id string
- instance
Id string - context
Get
Policy Vm Context - Get
Policy Vm Tag[] - 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
Get
Policy Vm Context - Sequence[Get
Policy Vm Tag] - A list of scope + tag pairs associated with this Virtual Machine.
- bios
Id String - description String
- The description of the Virtual Machine.
- display
Name String - external
Id String - id String
- instance
Id String - context Property Map
- List<Property Map>
- A list of scope + tag pairs associated with this Virtual Machine.
Supporting Types
GetPolicyVmContext
- Project
Id string - The ID of the project which the object belongs to
- Project
Id string - The ID of the project which the object belongs to
- project
Id String - The ID of the project which the object belongs to
- project
Id string - The ID of the project which the object belongs to
- project_
id str - The ID of the project which the object belongs to
- project
Id String - The ID of the project which the object belongs to
GetPolicyVmTag
Package Details
- Repository
- nsxt vmware/terraform-provider-nsxt
- License
- Notes
- This Pulumi package is based on the
nsxt
Terraform Provider.