1. Packages
  2. vSphere
  3. API Docs
  4. getResourcePool
vSphere v4.10.0 published on Tuesday, Mar 12, 2024 by Pulumi

vsphere.getResourcePool

Explore with Pulumi AI

vsphere logo
vSphere v4.10.0 published on Tuesday, Mar 12, 2024 by Pulumi

    The vsphere.ResourcePool data source can be used to discover the ID of a resource pool in vSphere. This is useful to return the ID of a resource pool that you want to use to create virtual machines in using the vsphere.VirtualMachine resource.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as vsphere from "@pulumi/vsphere";
    
    const datacenter = vsphere.getDatacenter({
        name: "dc-01",
    });
    const pool = datacenter.then(datacenter => vsphere.getResourcePool({
        name: "resource-pool-01",
        datacenterId: datacenter.id,
    }));
    
    import pulumi
    import pulumi_vsphere as vsphere
    
    datacenter = vsphere.get_datacenter(name="dc-01")
    pool = vsphere.get_resource_pool(name="resource-pool-01",
        datacenter_id=datacenter.id)
    
    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 {
    		datacenter, err := vsphere.LookupDatacenter(ctx, &vsphere.LookupDatacenterArgs{
    			Name: pulumi.StringRef("dc-01"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = vsphere.LookupResourcePool(ctx, &vsphere.LookupResourcePoolArgs{
    			Name:         pulumi.StringRef("resource-pool-01"),
    			DatacenterId: pulumi.StringRef(datacenter.Id),
    		}, 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 datacenter = VSphere.GetDatacenter.Invoke(new()
        {
            Name = "dc-01",
        });
    
        var pool = VSphere.GetResourcePool.Invoke(new()
        {
            Name = "resource-pool-01",
            DatacenterId = datacenter.Apply(getDatacenterResult => getDatacenterResult.Id),
        });
    
    });
    
    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.GetDatacenterArgs;
    import com.pulumi.vsphere.inputs.GetResourcePoolArgs;
    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 datacenter = VsphereFunctions.getDatacenter(GetDatacenterArgs.builder()
                .name("dc-01")
                .build());
    
            final var pool = VsphereFunctions.getResourcePool(GetResourcePoolArgs.builder()
                .name("resource-pool-01")
                .datacenterId(datacenter.applyValue(getDatacenterResult -> getDatacenterResult.id()))
                .build());
    
        }
    }
    
    variables:
      datacenter:
        fn::invoke:
          Function: vsphere:getDatacenter
          Arguments:
            name: dc-01
      pool:
        fn::invoke:
          Function: vsphere:getResourcePool
          Arguments:
            name: resource-pool-01
            datacenterId: ${datacenter.id}
    

    Specifying the Root Resource Pool for a Standalone ESXi Host

    NOTE: Returning the root resource pool for a cluster can be done directly via the vsphere.ComputeCluster data source.

    All compute resources in vSphere have a resource pool, even if one has not been explicitly created. This resource pool is referred to as the root resource pool and can be looked up by specifying the path.

    import * as pulumi from "@pulumi/pulumi";
    import * as vsphere from "@pulumi/vsphere";
    
    const pool = vsphere.getResourcePool({
        name: "esxi-01.example.com/Resources",
        datacenterId: data.vsphere_datacenter.datacenter.id,
    });
    
    import pulumi
    import pulumi_vsphere as vsphere
    
    pool = vsphere.get_resource_pool(name="esxi-01.example.com/Resources",
        datacenter_id=data["vsphere_datacenter"]["datacenter"]["id"])
    
    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.LookupResourcePool(ctx, &vsphere.LookupResourcePoolArgs{
    			Name:         pulumi.StringRef("esxi-01.example.com/Resources"),
    			DatacenterId: pulumi.StringRef(data.Vsphere_datacenter.Datacenter.Id),
    		}, 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 pool = VSphere.GetResourcePool.Invoke(new()
        {
            Name = "esxi-01.example.com/Resources",
            DatacenterId = data.Vsphere_datacenter.Datacenter.Id,
        });
    
    });
    
    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.GetResourcePoolArgs;
    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 pool = VsphereFunctions.getResourcePool(GetResourcePoolArgs.builder()
                .name("esxi-01.example.com/Resources")
                .datacenterId(data.vsphere_datacenter().datacenter().id())
                .build());
    
        }
    }
    
    variables:
      pool:
        fn::invoke:
          Function: vsphere:getResourcePool
          Arguments:
            name: esxi-01.example.com/Resources
            datacenterId: ${data.vsphere_datacenter.datacenter.id}
    

    For more information on the root resource pool, see Managing Resource Pools in the vSphere documentation.

    Using getResourcePool

    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 getResourcePool(args: GetResourcePoolArgs, opts?: InvokeOptions): Promise<GetResourcePoolResult>
    function getResourcePoolOutput(args: GetResourcePoolOutputArgs, opts?: InvokeOptions): Output<GetResourcePoolResult>
    def get_resource_pool(datacenter_id: Optional[str] = None,
                          name: Optional[str] = None,
                          opts: Optional[InvokeOptions] = None) -> GetResourcePoolResult
    def get_resource_pool_output(datacenter_id: Optional[pulumi.Input[str]] = None,
                          name: Optional[pulumi.Input[str]] = None,
                          opts: Optional[InvokeOptions] = None) -> Output[GetResourcePoolResult]
    func LookupResourcePool(ctx *Context, args *LookupResourcePoolArgs, opts ...InvokeOption) (*LookupResourcePoolResult, error)
    func LookupResourcePoolOutput(ctx *Context, args *LookupResourcePoolOutputArgs, opts ...InvokeOption) LookupResourcePoolResultOutput

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

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

    The following arguments are supported:

    DatacenterId string

    The managed object reference ID of the datacenter in which the resource pool is located. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere.Datacenter data source.

    Note: When using ESXi without a vCenter Server instance, you do not need to specify either attribute to use this data source. An empty declaration will load the ESXi host's root resource pool.

    Name string
    The name of the resource pool. This can be a name or path. This is required when using vCenter.
    DatacenterId string

    The managed object reference ID of the datacenter in which the resource pool is located. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere.Datacenter data source.

    Note: When using ESXi without a vCenter Server instance, you do not need to specify either attribute to use this data source. An empty declaration will load the ESXi host's root resource pool.

    Name string
    The name of the resource pool. This can be a name or path. This is required when using vCenter.
    datacenterId String

    The managed object reference ID of the datacenter in which the resource pool is located. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere.Datacenter data source.

    Note: When using ESXi without a vCenter Server instance, you do not need to specify either attribute to use this data source. An empty declaration will load the ESXi host's root resource pool.

    name String
    The name of the resource pool. This can be a name or path. This is required when using vCenter.
    datacenterId string

    The managed object reference ID of the datacenter in which the resource pool is located. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere.Datacenter data source.

    Note: When using ESXi without a vCenter Server instance, you do not need to specify either attribute to use this data source. An empty declaration will load the ESXi host's root resource pool.

    name string
    The name of the resource pool. This can be a name or path. This is required when using vCenter.
    datacenter_id str

    The managed object reference ID of the datacenter in which the resource pool is located. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere.Datacenter data source.

    Note: When using ESXi without a vCenter Server instance, you do not need to specify either attribute to use this data source. An empty declaration will load the ESXi host's root resource pool.

    name str
    The name of the resource pool. This can be a name or path. This is required when using vCenter.
    datacenterId String

    The managed object reference ID of the datacenter in which the resource pool is located. This can be omitted if the search path used in name is an absolute path. For default datacenters, use the id attribute from an empty vsphere.Datacenter data source.

    Note: When using ESXi without a vCenter Server instance, you do not need to specify either attribute to use this data source. An empty declaration will load the ESXi host's root resource pool.

    name String
    The name of the resource pool. This can be a name or path. This is required when using vCenter.

    getResourcePool Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    DatacenterId string
    Name string
    Id string
    The provider-assigned unique ID for this managed resource.
    DatacenterId string
    Name string
    id String
    The provider-assigned unique ID for this managed resource.
    datacenterId String
    name String
    id string
    The provider-assigned unique ID for this managed resource.
    datacenterId string
    name string
    id str
    The provider-assigned unique ID for this managed resource.
    datacenter_id str
    name str
    id String
    The provider-assigned unique ID for this managed resource.
    datacenterId String
    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.10.0 published on Tuesday, Mar 12, 2024 by Pulumi