vSphere v4.13.2 published on Wednesday, Apr 9, 2025 by Pulumi
vsphere.getComputeClusterHostGroup
Explore with Pulumi AI
The vsphere.ComputeClusterHostGroup data source can be used to discover
the IDs ESXi hosts in a host group and return host group attributes to other
resources.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as vsphere from "@pulumi/vsphere";
const datacenter = vsphere.getDatacenter({
    name: "dc-01",
});
const cluster = datacenter.then(datacenter => vsphere.getComputeCluster({
    name: "cluster-01",
    datacenterId: datacenter.id,
}));
const hostGroup = cluster.then(cluster => vsphere.getComputeClusterHostGroup({
    name: "hostgroup-01",
    computeClusterId: cluster.id,
}));
const hostRule = new vsphere.ComputeClusterVmHostRule("host_rule", {
    computeClusterId: cluster.then(cluster => cluster.id),
    name: "pulumi-host-rule1",
    vmGroupName: "vmgroup-01",
    affinityHostGroupName: hostGroup.then(hostGroup => hostGroup.name),
});
import pulumi
import pulumi_vsphere as vsphere
datacenter = vsphere.get_datacenter(name="dc-01")
cluster = vsphere.get_compute_cluster(name="cluster-01",
    datacenter_id=datacenter.id)
host_group = vsphere.get_compute_cluster_host_group(name="hostgroup-01",
    compute_cluster_id=cluster.id)
host_rule = vsphere.ComputeClusterVmHostRule("host_rule",
    compute_cluster_id=cluster.id,
    name="pulumi-host-rule1",
    vm_group_name="vmgroup-01",
    affinity_host_group_name=host_group.name)
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
		}
		cluster, err := vsphere.LookupComputeCluster(ctx, &vsphere.LookupComputeClusterArgs{
			Name:         "cluster-01",
			DatacenterId: pulumi.StringRef(datacenter.Id),
		}, nil)
		if err != nil {
			return err
		}
		hostGroup, err := vsphere.LookupComputeClusterHostGroup(ctx, &vsphere.LookupComputeClusterHostGroupArgs{
			Name:             "hostgroup-01",
			ComputeClusterId: cluster.Id,
		}, nil)
		if err != nil {
			return err
		}
		_, err = vsphere.NewComputeClusterVmHostRule(ctx, "host_rule", &vsphere.ComputeClusterVmHostRuleArgs{
			ComputeClusterId:      pulumi.String(cluster.Id),
			Name:                  pulumi.String("pulumi-host-rule1"),
			VmGroupName:           pulumi.String("vmgroup-01"),
			AffinityHostGroupName: pulumi.String(hostGroup.Name),
		})
		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 cluster = VSphere.GetComputeCluster.Invoke(new()
    {
        Name = "cluster-01",
        DatacenterId = datacenter.Apply(getDatacenterResult => getDatacenterResult.Id),
    });
    var hostGroup = VSphere.GetComputeClusterHostGroup.Invoke(new()
    {
        Name = "hostgroup-01",
        ComputeClusterId = cluster.Apply(getComputeClusterResult => getComputeClusterResult.Id),
    });
    var hostRule = new VSphere.ComputeClusterVmHostRule("host_rule", new()
    {
        ComputeClusterId = cluster.Apply(getComputeClusterResult => getComputeClusterResult.Id),
        Name = "pulumi-host-rule1",
        VmGroupName = "vmgroup-01",
        AffinityHostGroupName = hostGroup.Apply(getComputeClusterHostGroupResult => getComputeClusterHostGroupResult.Name),
    });
});
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.GetComputeClusterArgs;
import com.pulumi.vsphere.inputs.GetComputeClusterHostGroupArgs;
import com.pulumi.vsphere.ComputeClusterVmHostRule;
import com.pulumi.vsphere.ComputeClusterVmHostRuleArgs;
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 cluster = VsphereFunctions.getComputeCluster(GetComputeClusterArgs.builder()
            .name("cluster-01")
            .datacenterId(datacenter.id())
            .build());
        final var hostGroup = VsphereFunctions.getComputeClusterHostGroup(GetComputeClusterHostGroupArgs.builder()
            .name("hostgroup-01")
            .computeClusterId(cluster.id())
            .build());
        var hostRule = new ComputeClusterVmHostRule("hostRule", ComputeClusterVmHostRuleArgs.builder()
            .computeClusterId(cluster.id())
            .name("pulumi-host-rule1")
            .vmGroupName("vmgroup-01")
            .affinityHostGroupName(hostGroup.name())
            .build());
    }
}
resources:
  hostRule:
    type: vsphere:ComputeClusterVmHostRule
    name: host_rule
    properties:
      computeClusterId: ${cluster.id}
      name: pulumi-host-rule1
      vmGroupName: vmgroup-01
      affinityHostGroupName: ${hostGroup.name}
variables:
  datacenter:
    fn::invoke:
      function: vsphere:getDatacenter
      arguments:
        name: dc-01
  cluster:
    fn::invoke:
      function: vsphere:getComputeCluster
      arguments:
        name: cluster-01
        datacenterId: ${datacenter.id}
  hostGroup:
    fn::invoke:
      function: vsphere:getComputeClusterHostGroup
      arguments:
        name: hostgroup-01
        computeClusterId: ${cluster.id}
Using getComputeClusterHostGroup
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 getComputeClusterHostGroup(args: GetComputeClusterHostGroupArgs, opts?: InvokeOptions): Promise<GetComputeClusterHostGroupResult>
function getComputeClusterHostGroupOutput(args: GetComputeClusterHostGroupOutputArgs, opts?: InvokeOptions): Output<GetComputeClusterHostGroupResult>def get_compute_cluster_host_group(compute_cluster_id: Optional[str] = None,
                                   name: Optional[str] = None,
                                   opts: Optional[InvokeOptions] = None) -> GetComputeClusterHostGroupResult
def get_compute_cluster_host_group_output(compute_cluster_id: Optional[pulumi.Input[str]] = None,
                                   name: Optional[pulumi.Input[str]] = None,
                                   opts: Optional[InvokeOptions] = None) -> Output[GetComputeClusterHostGroupResult]func LookupComputeClusterHostGroup(ctx *Context, args *LookupComputeClusterHostGroupArgs, opts ...InvokeOption) (*LookupComputeClusterHostGroupResult, error)
func LookupComputeClusterHostGroupOutput(ctx *Context, args *LookupComputeClusterHostGroupOutputArgs, opts ...InvokeOption) LookupComputeClusterHostGroupResultOutput> Note: This function is named LookupComputeClusterHostGroup in the Go SDK.
public static class GetComputeClusterHostGroup 
{
    public static Task<GetComputeClusterHostGroupResult> InvokeAsync(GetComputeClusterHostGroupArgs args, InvokeOptions? opts = null)
    public static Output<GetComputeClusterHostGroupResult> Invoke(GetComputeClusterHostGroupInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetComputeClusterHostGroupResult> getComputeClusterHostGroup(GetComputeClusterHostGroupArgs args, InvokeOptions options)
public static Output<GetComputeClusterHostGroupResult> getComputeClusterHostGroup(GetComputeClusterHostGroupArgs args, InvokeOptions options)
fn::invoke:
  function: vsphere:index/getComputeClusterHostGroup:getComputeClusterHostGroup
  arguments:
    # arguments dictionaryThe following arguments are supported:
- Compute
Cluster stringId  - The managed object reference ID of the compute cluster for the host group.
 - Name string
 - The name of the host group.
 
- Compute
Cluster stringId  - The managed object reference ID of the compute cluster for the host group.
 - Name string
 - The name of the host group.
 
- compute
Cluster StringId  - The managed object reference ID of the compute cluster for the host group.
 - name String
 - The name of the host group.
 
- compute
Cluster stringId  - The managed object reference ID of the compute cluster for the host group.
 - name string
 - The name of the host group.
 
- compute_
cluster_ strid  - The managed object reference ID of the compute cluster for the host group.
 - name str
 - The name of the host group.
 
- compute
Cluster StringId  - The managed object reference ID of the compute cluster for the host group.
 - name String
 - The name of the host group.
 
getComputeClusterHostGroup Result
The following output properties are available:
- Compute
Cluster stringId  - Host
System List<string>Ids  - The [managed object reference ID][docs-about-morefs] of the ESXi hosts in the host group.
 - Id string
 - The provider-assigned unique ID for this managed resource.
 - Name string
 
- Compute
Cluster stringId  - Host
System []stringIds  - The [managed object reference ID][docs-about-morefs] of the ESXi hosts in the host group.
 - Id string
 - The provider-assigned unique ID for this managed resource.
 - Name string
 
- compute
Cluster StringId  - host
System List<String>Ids  - The [managed object reference ID][docs-about-morefs] of the ESXi hosts in the host group.
 - id String
 - The provider-assigned unique ID for this managed resource.
 - name String
 
- compute
Cluster stringId  - host
System string[]Ids  - The [managed object reference ID][docs-about-morefs] of the ESXi hosts in the host group.
 - id string
 - The provider-assigned unique ID for this managed resource.
 - name string
 
- compute_
cluster_ strid  - host_
system_ Sequence[str]ids  - The [managed object reference ID][docs-about-morefs] of the ESXi hosts in the host group.
 - id str
 - The provider-assigned unique ID for this managed resource.
 - name str
 
- compute
Cluster StringId  - host
System List<String>Ids  - The [managed object reference ID][docs-about-morefs] of the ESXi hosts in the host group.
 - 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 
vsphereTerraform Provider.