vcd.getVmPlacementPolicy
Explore with Pulumi AI
Provides a VMware Cloud Director VM Placement Policy data source. This can be used to read a VM Placement Policy.
Supported in provider v3.8+ and requires VCD 10.2+
Note: This resource can be used by both system administrators and tenant users.
Example Usage
System Administrators
System administrators have full privileges to retrieve information of the Provider VDC to which the VM Placement Policy belongs. The way to fetch a VM Placement Policy in this case would be:
import * as pulumi from "@pulumi/pulumi";
import * as vcd from "@pulumi/vcd";
const my_vdc = vcd.getOrgVdc({
org: "test",
name: "vdc-test",
});
const my_pvdc = my_vdc.then(my_vdc => vcd.getProviderVdc({
name: my_vdc.providerVdcName,
}));
const tf_policy_name = my_pvdc.then(my_pvdc => vcd.getVmPlacementPolicy({
name: "my-policy",
providerVdcId: my_pvdc.id,
}));
export const policyId = tf_policy_name.then(tf_policy_name => tf_policy_name.id);
import pulumi
import pulumi_vcd as vcd
my_vdc = vcd.get_org_vdc(org="test",
name="vdc-test")
my_pvdc = vcd.get_provider_vdc(name=my_vdc.provider_vdc_name)
tf_policy_name = vcd.get_vm_placement_policy(name="my-policy",
provider_vdc_id=my_pvdc.id)
pulumi.export("policyId", tf_policy_name.id)
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/vcd/v3/vcd"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
my_vdc, err := vcd.LookupOrgVdc(ctx, &vcd.LookupOrgVdcArgs{
Org: pulumi.StringRef("test"),
Name: "vdc-test",
}, nil)
if err != nil {
return err
}
my_pvdc, err := vcd.LookupProviderVdc(ctx, &vcd.LookupProviderVdcArgs{
Name: my_vdc.ProviderVdcName,
}, nil)
if err != nil {
return err
}
tf_policy_name, err := vcd.LookupVmPlacementPolicy(ctx, &vcd.LookupVmPlacementPolicyArgs{
Name: "my-policy",
ProviderVdcId: pulumi.StringRef(my_pvdc.Id),
}, nil)
if err != nil {
return err
}
ctx.Export("policyId", tf_policy_name.Id)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Vcd = Pulumi.Vcd;
return await Deployment.RunAsync(() =>
{
var my_vdc = Vcd.GetOrgVdc.Invoke(new()
{
Org = "test",
Name = "vdc-test",
});
var my_pvdc = Vcd.GetProviderVdc.Invoke(new()
{
Name = my_vdc.Apply(getOrgVdcResult => getOrgVdcResult.ProviderVdcName),
});
var tf_policy_name = Vcd.GetVmPlacementPolicy.Invoke(new()
{
Name = "my-policy",
ProviderVdcId = my_pvdc.Apply(getProviderVdcResult => getProviderVdcResult.Id),
});
return new Dictionary<string, object?>
{
["policyId"] = tf_policy_name.Apply(tf_policy_name => tf_policy_name.Apply(getVmPlacementPolicyResult => getVmPlacementPolicyResult.Id)),
};
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.vcd.VcdFunctions;
import com.pulumi.vcd.inputs.GetOrgVdcArgs;
import com.pulumi.vcd.inputs.GetProviderVdcArgs;
import com.pulumi.vcd.inputs.GetVmPlacementPolicyArgs;
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 my-vdc = VcdFunctions.getOrgVdc(GetOrgVdcArgs.builder()
.org("test")
.name("vdc-test")
.build());
final var my-pvdc = VcdFunctions.getProviderVdc(GetProviderVdcArgs.builder()
.name(my_vdc.providerVdcName())
.build());
final var tf-policy-name = VcdFunctions.getVmPlacementPolicy(GetVmPlacementPolicyArgs.builder()
.name("my-policy")
.providerVdcId(my_pvdc.id())
.build());
ctx.export("policyId", tf_policy_name.id());
}
}
variables:
my-vdc:
fn::invoke:
function: vcd:getOrgVdc
arguments:
org: test
name: vdc-test
my-pvdc:
fn::invoke:
function: vcd:getProviderVdc
arguments:
name: ${["my-vdc"].providerVdcName}
tf-policy-name:
fn::invoke:
function: vcd:getVmPlacementPolicy
arguments:
name: my-policy
providerVdcId: ${["my-pvdc"].id}
outputs:
policyId: ${["tf-policy-name"].id}
Tenant Users
Tenant users don’t have access to Provider VDC information so the only way to retrieve VM Placement Policies is to fetch them using the VDC information. The only constraint is that the desired VM Placement Policy must be assigned to the VDC.
import * as pulumi from "@pulumi/pulumi";
import * as vcd from "@pulumi/vcd";
const my_vdc = vcd.getOrgVdc({
org: "test",
name: "vdc-test",
});
const tf_policy_name = my_vdc.then(my_vdc => vcd.getVmPlacementPolicy({
name: "my-policy",
vdcId: my_vdc.id,
}));
export const policyId = tf_policy_name.then(tf_policy_name => tf_policy_name.id);
import pulumi
import pulumi_vcd as vcd
my_vdc = vcd.get_org_vdc(org="test",
name="vdc-test")
tf_policy_name = vcd.get_vm_placement_policy(name="my-policy",
vdc_id=my_vdc.id)
pulumi.export("policyId", tf_policy_name.id)
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/vcd/v3/vcd"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
my_vdc, err := vcd.LookupOrgVdc(ctx, &vcd.LookupOrgVdcArgs{
Org: pulumi.StringRef("test"),
Name: "vdc-test",
}, nil)
if err != nil {
return err
}
tf_policy_name, err := vcd.LookupVmPlacementPolicy(ctx, &vcd.LookupVmPlacementPolicyArgs{
Name: "my-policy",
VdcId: pulumi.StringRef(my_vdc.Id),
}, nil)
if err != nil {
return err
}
ctx.Export("policyId", tf_policy_name.Id)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Vcd = Pulumi.Vcd;
return await Deployment.RunAsync(() =>
{
var my_vdc = Vcd.GetOrgVdc.Invoke(new()
{
Org = "test",
Name = "vdc-test",
});
var tf_policy_name = Vcd.GetVmPlacementPolicy.Invoke(new()
{
Name = "my-policy",
VdcId = my_vdc.Apply(getOrgVdcResult => getOrgVdcResult.Id),
});
return new Dictionary<string, object?>
{
["policyId"] = tf_policy_name.Apply(tf_policy_name => tf_policy_name.Apply(getVmPlacementPolicyResult => getVmPlacementPolicyResult.Id)),
};
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.vcd.VcdFunctions;
import com.pulumi.vcd.inputs.GetOrgVdcArgs;
import com.pulumi.vcd.inputs.GetVmPlacementPolicyArgs;
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 my-vdc = VcdFunctions.getOrgVdc(GetOrgVdcArgs.builder()
.org("test")
.name("vdc-test")
.build());
final var tf-policy-name = VcdFunctions.getVmPlacementPolicy(GetVmPlacementPolicyArgs.builder()
.name("my-policy")
.vdcId(my_vdc.id())
.build());
ctx.export("policyId", tf_policy_name.id());
}
}
variables:
my-vdc:
fn::invoke:
function: vcd:getOrgVdc
arguments:
org: test
name: vdc-test
tf-policy-name:
fn::invoke:
function: vcd:getVmPlacementPolicy
arguments:
name: my-policy
vdcId: ${["my-vdc"].id}
outputs:
policyId: ${["tf-policy-name"].id}
Using getVmPlacementPolicy
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 getVmPlacementPolicy(args: GetVmPlacementPolicyArgs, opts?: InvokeOptions): Promise<GetVmPlacementPolicyResult>
function getVmPlacementPolicyOutput(args: GetVmPlacementPolicyOutputArgs, opts?: InvokeOptions): Output<GetVmPlacementPolicyResult>
def get_vm_placement_policy(id: Optional[str] = None,
name: Optional[str] = None,
provider_vdc_id: Optional[str] = None,
vdc_id: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetVmPlacementPolicyResult
def get_vm_placement_policy_output(id: Optional[pulumi.Input[str]] = None,
name: Optional[pulumi.Input[str]] = None,
provider_vdc_id: Optional[pulumi.Input[str]] = None,
vdc_id: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetVmPlacementPolicyResult]
func LookupVmPlacementPolicy(ctx *Context, args *LookupVmPlacementPolicyArgs, opts ...InvokeOption) (*LookupVmPlacementPolicyResult, error)
func LookupVmPlacementPolicyOutput(ctx *Context, args *LookupVmPlacementPolicyOutputArgs, opts ...InvokeOption) LookupVmPlacementPolicyResultOutput
> Note: This function is named LookupVmPlacementPolicy
in the Go SDK.
public static class GetVmPlacementPolicy
{
public static Task<GetVmPlacementPolicyResult> InvokeAsync(GetVmPlacementPolicyArgs args, InvokeOptions? opts = null)
public static Output<GetVmPlacementPolicyResult> Invoke(GetVmPlacementPolicyInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetVmPlacementPolicyResult> getVmPlacementPolicy(GetVmPlacementPolicyArgs args, InvokeOptions options)
public static Output<GetVmPlacementPolicyResult> getVmPlacementPolicy(GetVmPlacementPolicyArgs args, InvokeOptions options)
fn::invoke:
function: vcd:index/getVmPlacementPolicy:getVmPlacementPolicy
arguments:
# arguments dictionary
The following arguments are supported:
- Name string
- The name VM Placement Policy.
- Id string
- Provider
Vdc stringId - The ID of the Provider VDC to which the VM Placement Policy belongs.
- Vdc
Id string - The ID of the VDC to which the VM Placement Policy is assigned.
- Name string
- The name VM Placement Policy.
- Id string
- Provider
Vdc stringId - The ID of the Provider VDC to which the VM Placement Policy belongs.
- Vdc
Id string - The ID of the VDC to which the VM Placement Policy is assigned.
- name String
- The name VM Placement Policy.
- id String
- provider
Vdc StringId - The ID of the Provider VDC to which the VM Placement Policy belongs.
- vdc
Id String - The ID of the VDC to which the VM Placement Policy is assigned.
- name string
- The name VM Placement Policy.
- id string
- provider
Vdc stringId - The ID of the Provider VDC to which the VM Placement Policy belongs.
- vdc
Id string - The ID of the VDC to which the VM Placement Policy is assigned.
- name str
- The name VM Placement Policy.
- id str
- provider_
vdc_ strid - The ID of the Provider VDC to which the VM Placement Policy belongs.
- vdc_
id str - The ID of the VDC to which the VM Placement Policy is assigned.
- name String
- The name VM Placement Policy.
- id String
- provider
Vdc StringId - The ID of the Provider VDC to which the VM Placement Policy belongs.
- vdc
Id String - The ID of the VDC to which the VM Placement Policy is assigned.
getVmPlacementPolicy Result
The following output properties are available:
- Description string
- Id string
- Logical
Vm List<string>Group Ids - This attribute can't be retrieved if the data source is used by a tenant user when fetching by
vdc_id
. - Name string
- Vm
Group List<string>Ids - This attribute can't be retrieved if the data source is used by a tenant user when fetching by
vdc_id
. - Provider
Vdc stringId - Vdc
Id string
- Description string
- Id string
- Logical
Vm []stringGroup Ids - This attribute can't be retrieved if the data source is used by a tenant user when fetching by
vdc_id
. - Name string
- Vm
Group []stringIds - This attribute can't be retrieved if the data source is used by a tenant user when fetching by
vdc_id
. - Provider
Vdc stringId - Vdc
Id string
- description String
- id String
- logical
Vm List<String>Group Ids - This attribute can't be retrieved if the data source is used by a tenant user when fetching by
vdc_id
. - name String
- vm
Group List<String>Ids - This attribute can't be retrieved if the data source is used by a tenant user when fetching by
vdc_id
. - provider
Vdc StringId - vdc
Id String
- description string
- id string
- logical
Vm string[]Group Ids - This attribute can't be retrieved if the data source is used by a tenant user when fetching by
vdc_id
. - name string
- vm
Group string[]Ids - This attribute can't be retrieved if the data source is used by a tenant user when fetching by
vdc_id
. - provider
Vdc stringId - vdc
Id string
- description str
- id str
- logical_
vm_ Sequence[str]group_ ids - This attribute can't be retrieved if the data source is used by a tenant user when fetching by
vdc_id
. - name str
- vm_
group_ Sequence[str]ids - This attribute can't be retrieved if the data source is used by a tenant user when fetching by
vdc_id
. - provider_
vdc_ strid - vdc_
id str
- description String
- id String
- logical
Vm List<String>Group Ids - This attribute can't be retrieved if the data source is used by a tenant user when fetching by
vdc_id
. - name String
- vm
Group List<String>Ids - This attribute can't be retrieved if the data source is used by a tenant user when fetching by
vdc_id
. - provider
Vdc StringId - vdc
Id String
Package Details
- Repository
- vcd vmware/terraform-provider-vcd
- License
- Notes
- This Pulumi package is based on the
vcd
Terraform Provider.