1. Packages
  2. Vsphere Provider
  3. API Docs
  4. getPolicy
vSphere v4.12.1 published on Tuesday, Oct 22, 2024 by Pulumi

vsphere.getPolicy

Explore with Pulumi AI

vsphere logo
vSphere v4.12.1 published on Tuesday, Oct 22, 2024 by Pulumi

    The vsphere.getPolicy data source can be used to discover the UUID of a storage policy. This can then be used with other resources or data sources that use a storage policy.

    NOTE: Storage policies are not supported on direct ESXi hosts and requires vCenter Server.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as vsphere from "@pulumi/vsphere";
    
    const prodPlatinumReplicated = vsphere.getPolicy({
        name: "prod_platinum_replicated",
    });
    const devSilverNonreplicated = vsphere.getPolicy({
        name: "dev_silver_nonreplicated",
    });
    
    import pulumi
    import pulumi_vsphere as vsphere
    
    prod_platinum_replicated = vsphere.get_policy(name="prod_platinum_replicated")
    dev_silver_nonreplicated = vsphere.get_policy(name="dev_silver_nonreplicated")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-vsphere/sdk/v4/go/vsphere"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := vsphere.GetPolicy(ctx, &vsphere.GetPolicyArgs{
    			Name: "prod_platinum_replicated",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = vsphere.GetPolicy(ctx, &vsphere.GetPolicyArgs{
    			Name: "dev_silver_nonreplicated",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using VSphere = Pulumi.VSphere;
    
    return await Deployment.RunAsync(() => 
    {
        var prodPlatinumReplicated = VSphere.GetPolicy.Invoke(new()
        {
            Name = "prod_platinum_replicated",
        });
    
        var devSilverNonreplicated = VSphere.GetPolicy.Invoke(new()
        {
            Name = "dev_silver_nonreplicated",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.vsphere.VsphereFunctions;
    import com.pulumi.vsphere.inputs.GetPolicyArgs;
    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 prodPlatinumReplicated = VsphereFunctions.getPolicy(GetPolicyArgs.builder()
                .name("prod_platinum_replicated")
                .build());
    
            final var devSilverNonreplicated = VsphereFunctions.getPolicy(GetPolicyArgs.builder()
                .name("dev_silver_nonreplicated")
                .build());
    
        }
    }
    
    variables:
      prodPlatinumReplicated:
        fn::invoke:
          Function: vsphere:getPolicy
          Arguments:
            name: prod_platinum_replicated
      devSilverNonreplicated:
        fn::invoke:
          Function: vsphere:getPolicy
          Arguments:
            name: dev_silver_nonreplicated
    

    Using getPolicy

    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 getPolicy(args: GetPolicyArgs, opts?: InvokeOptions): Promise<GetPolicyResult>
    function getPolicyOutput(args: GetPolicyOutputArgs, opts?: InvokeOptions): Output<GetPolicyResult>
    def get_policy(name: Optional[str] = None,
                   opts: Optional[InvokeOptions] = None) -> GetPolicyResult
    def get_policy_output(name: Optional[pulumi.Input[str]] = None,
                   opts: Optional[InvokeOptions] = None) -> Output[GetPolicyResult]
    func GetPolicy(ctx *Context, args *GetPolicyArgs, opts ...InvokeOption) (*GetPolicyResult, error)
    func GetPolicyOutput(ctx *Context, args *GetPolicyOutputArgs, opts ...InvokeOption) GetPolicyResultOutput

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

    public static class GetPolicy 
    {
        public static Task<GetPolicyResult> InvokeAsync(GetPolicyArgs args, InvokeOptions? opts = null)
        public static Output<GetPolicyResult> Invoke(GetPolicyInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetPolicyResult> getPolicy(GetPolicyArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: vsphere:index/getPolicy:getPolicy
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Name string
    The name of the storage policy.
    Name string
    The name of the storage policy.
    name String
    The name of the storage policy.
    name string
    The name of the storage policy.
    name str
    The name of the storage policy.
    name String
    The name of the storage policy.

    getPolicy Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    id string
    The provider-assigned unique ID for this managed resource.
    name string
    id str
    The provider-assigned unique ID for this managed resource.
    name str
    id String
    The provider-assigned unique ID for this managed resource.
    name String

    Package Details

    Repository
    vSphere pulumi/pulumi-vsphere
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the vsphere Terraform Provider.
    vsphere logo
    vSphere v4.12.1 published on Tuesday, Oct 22, 2024 by Pulumi