1. Packages
  2. Vsphere Provider
  3. API Docs
  4. ComputeClusterVmHostRule
vSphere v4.13.2 published on Wednesday, Apr 9, 2025 by Pulumi

vsphere.ComputeClusterVmHostRule

Explore with Pulumi AI

The vsphere.ComputeClusterVmHostRule resource can be used to manage VM-to-host rules in a cluster, either created by the vsphere.ComputeCluster resource or looked up by the vsphere.ComputeCluster data source.

This resource can create both affinity rules, where virtual machines run on specified hosts, or anti-affinity rules, where virtual machines run on hosts outside of the ones specified in the rule. Virtual machines and hosts are supplied via groups, which can be managed via the vsphere.ComputeClusterVmGroup and vsphere.ComputeClusterHostGroup resources.

NOTE: This resource requires vCenter and is not available on direct ESXi connections.

Example Usage

The example below creates a virtual machine in a cluster using the vsphere.VirtualMachine resource in a cluster looked up by the vsphere.ComputeCluster data source. It then creates a group with this virtual machine. It also creates a host group off of the host looked up via the vsphere.Host data source. Finally, this virtual machine is configured to run specifically on that host via a vsphere.ComputeClusterVmHostRule resource.

Note how vm_group_name and affinity_host_group_name are sourced off of the name attributes from the vsphere.ComputeClusterVmGroup and vsphere.ComputeClusterHostGroup resources. This is to ensure that the rule is not created before the groups exist, which may not possibly happen in the event that the names came from a “static” source such as a variable.

import * as pulumi from "@pulumi/pulumi";
import * as vsphere from "@pulumi/vsphere";

const datacenter = vsphere.getDatacenter({
    name: "dc-01",
});
const datastore = datacenter.then(datacenter => vsphere.getDatastore({
    name: "datastore1",
    datacenterId: datacenter.id,
}));
const cluster = datacenter.then(datacenter => vsphere.getComputeCluster({
    name: "cluster-01",
    datacenterId: datacenter.id,
}));
const host = datacenter.then(datacenter => vsphere.getHost({
    name: "esxi-01.example.com",
    datacenterId: datacenter.id,
}));
const network = datacenter.then(datacenter => vsphere.getNetwork({
    name: "network1",
    datacenterId: datacenter.id,
}));
const vm = new vsphere.VirtualMachine("vm", {
    name: "test",
    resourcePoolId: cluster.then(cluster => cluster.resourcePoolId),
    datastoreId: datastore.then(datastore => datastore.id),
    numCpus: 2,
    memory: 2048,
    guestId: "otherLinux64Guest",
    networkInterfaces: [{
        networkId: network.then(network => network.id),
    }],
    disks: [{
        label: "disk0",
        size: 20,
    }],
});
const clusterVmGroup = new vsphere.ComputeClusterVmGroup("cluster_vm_group", {
    name: "test-cluster-vm-group",
    computeClusterId: cluster.then(cluster => cluster.id),
    virtualMachineIds: [vm.id],
});
const clusterHostGroup = new vsphere.ComputeClusterHostGroup("cluster_host_group", {
    name: "test-cluster-vm-group",
    computeClusterId: cluster.then(cluster => cluster.id),
    hostSystemIds: [host.then(host => host.id)],
});
const clusterVmHostRule = new vsphere.ComputeClusterVmHostRule("cluster_vm_host_rule", {
    computeClusterId: cluster.then(cluster => cluster.id),
    name: "test-cluster-vm-host-rule",
    vmGroupName: clusterVmGroup.name,
    affinityHostGroupName: clusterHostGroup.name,
});
Copy
import pulumi
import pulumi_vsphere as vsphere

datacenter = vsphere.get_datacenter(name="dc-01")
datastore = vsphere.get_datastore(name="datastore1",
    datacenter_id=datacenter.id)
cluster = vsphere.get_compute_cluster(name="cluster-01",
    datacenter_id=datacenter.id)
host = vsphere.get_host(name="esxi-01.example.com",
    datacenter_id=datacenter.id)
network = vsphere.get_network(name="network1",
    datacenter_id=datacenter.id)
vm = vsphere.VirtualMachine("vm",
    name="test",
    resource_pool_id=cluster.resource_pool_id,
    datastore_id=datastore.id,
    num_cpus=2,
    memory=2048,
    guest_id="otherLinux64Guest",
    network_interfaces=[{
        "network_id": network.id,
    }],
    disks=[{
        "label": "disk0",
        "size": 20,
    }])
cluster_vm_group = vsphere.ComputeClusterVmGroup("cluster_vm_group",
    name="test-cluster-vm-group",
    compute_cluster_id=cluster.id,
    virtual_machine_ids=[vm.id])
cluster_host_group = vsphere.ComputeClusterHostGroup("cluster_host_group",
    name="test-cluster-vm-group",
    compute_cluster_id=cluster.id,
    host_system_ids=[host.id])
cluster_vm_host_rule = vsphere.ComputeClusterVmHostRule("cluster_vm_host_rule",
    compute_cluster_id=cluster.id,
    name="test-cluster-vm-host-rule",
    vm_group_name=cluster_vm_group.name,
    affinity_host_group_name=cluster_host_group.name)
Copy
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
		}
		datastore, err := vsphere.GetDatastore(ctx, &vsphere.GetDatastoreArgs{
			Name:         "datastore1",
			DatacenterId: pulumi.StringRef(datacenter.Id),
		}, 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
		}
		host, err := vsphere.LookupHost(ctx, &vsphere.LookupHostArgs{
			Name:         pulumi.StringRef("esxi-01.example.com"),
			DatacenterId: datacenter.Id,
		}, nil)
		if err != nil {
			return err
		}
		network, err := vsphere.GetNetwork(ctx, &vsphere.GetNetworkArgs{
			Name:         "network1",
			DatacenterId: pulumi.StringRef(datacenter.Id),
		}, nil)
		if err != nil {
			return err
		}
		vm, err := vsphere.NewVirtualMachine(ctx, "vm", &vsphere.VirtualMachineArgs{
			Name:           pulumi.String("test"),
			ResourcePoolId: pulumi.String(cluster.ResourcePoolId),
			DatastoreId:    pulumi.String(datastore.Id),
			NumCpus:        pulumi.Int(2),
			Memory:         pulumi.Int(2048),
			GuestId:        pulumi.String("otherLinux64Guest"),
			NetworkInterfaces: vsphere.VirtualMachineNetworkInterfaceArray{
				&vsphere.VirtualMachineNetworkInterfaceArgs{
					NetworkId: pulumi.String(network.Id),
				},
			},
			Disks: vsphere.VirtualMachineDiskArray{
				&vsphere.VirtualMachineDiskArgs{
					Label: pulumi.String("disk0"),
					Size:  pulumi.Int(20),
				},
			},
		})
		if err != nil {
			return err
		}
		clusterVmGroup, err := vsphere.NewComputeClusterVmGroup(ctx, "cluster_vm_group", &vsphere.ComputeClusterVmGroupArgs{
			Name:             pulumi.String("test-cluster-vm-group"),
			ComputeClusterId: pulumi.String(cluster.Id),
			VirtualMachineIds: pulumi.StringArray{
				vm.ID(),
			},
		})
		if err != nil {
			return err
		}
		clusterHostGroup, err := vsphere.NewComputeClusterHostGroup(ctx, "cluster_host_group", &vsphere.ComputeClusterHostGroupArgs{
			Name:             pulumi.String("test-cluster-vm-group"),
			ComputeClusterId: pulumi.String(cluster.Id),
			HostSystemIds: pulumi.StringArray{
				pulumi.String(host.Id),
			},
		})
		if err != nil {
			return err
		}
		_, err = vsphere.NewComputeClusterVmHostRule(ctx, "cluster_vm_host_rule", &vsphere.ComputeClusterVmHostRuleArgs{
			ComputeClusterId:      pulumi.String(cluster.Id),
			Name:                  pulumi.String("test-cluster-vm-host-rule"),
			VmGroupName:           clusterVmGroup.Name,
			AffinityHostGroupName: clusterHostGroup.Name,
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
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 datastore = VSphere.GetDatastore.Invoke(new()
    {
        Name = "datastore1",
        DatacenterId = datacenter.Apply(getDatacenterResult => getDatacenterResult.Id),
    });

    var cluster = VSphere.GetComputeCluster.Invoke(new()
    {
        Name = "cluster-01",
        DatacenterId = datacenter.Apply(getDatacenterResult => getDatacenterResult.Id),
    });

    var host = VSphere.GetHost.Invoke(new()
    {
        Name = "esxi-01.example.com",
        DatacenterId = datacenter.Apply(getDatacenterResult => getDatacenterResult.Id),
    });

    var network = VSphere.GetNetwork.Invoke(new()
    {
        Name = "network1",
        DatacenterId = datacenter.Apply(getDatacenterResult => getDatacenterResult.Id),
    });

    var vm = new VSphere.VirtualMachine("vm", new()
    {
        Name = "test",
        ResourcePoolId = cluster.Apply(getComputeClusterResult => getComputeClusterResult.ResourcePoolId),
        DatastoreId = datastore.Apply(getDatastoreResult => getDatastoreResult.Id),
        NumCpus = 2,
        Memory = 2048,
        GuestId = "otherLinux64Guest",
        NetworkInterfaces = new[]
        {
            new VSphere.Inputs.VirtualMachineNetworkInterfaceArgs
            {
                NetworkId = network.Apply(getNetworkResult => getNetworkResult.Id),
            },
        },
        Disks = new[]
        {
            new VSphere.Inputs.VirtualMachineDiskArgs
            {
                Label = "disk0",
                Size = 20,
            },
        },
    });

    var clusterVmGroup = new VSphere.ComputeClusterVmGroup("cluster_vm_group", new()
    {
        Name = "test-cluster-vm-group",
        ComputeClusterId = cluster.Apply(getComputeClusterResult => getComputeClusterResult.Id),
        VirtualMachineIds = new[]
        {
            vm.Id,
        },
    });

    var clusterHostGroup = new VSphere.ComputeClusterHostGroup("cluster_host_group", new()
    {
        Name = "test-cluster-vm-group",
        ComputeClusterId = cluster.Apply(getComputeClusterResult => getComputeClusterResult.Id),
        HostSystemIds = new[]
        {
            host.Apply(getHostResult => getHostResult.Id),
        },
    });

    var clusterVmHostRule = new VSphere.ComputeClusterVmHostRule("cluster_vm_host_rule", new()
    {
        ComputeClusterId = cluster.Apply(getComputeClusterResult => getComputeClusterResult.Id),
        Name = "test-cluster-vm-host-rule",
        VmGroupName = clusterVmGroup.Name,
        AffinityHostGroupName = clusterHostGroup.Name,
    });

});
Copy
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.GetDatastoreArgs;
import com.pulumi.vsphere.inputs.GetComputeClusterArgs;
import com.pulumi.vsphere.inputs.GetHostArgs;
import com.pulumi.vsphere.inputs.GetNetworkArgs;
import com.pulumi.vsphere.VirtualMachine;
import com.pulumi.vsphere.VirtualMachineArgs;
import com.pulumi.vsphere.inputs.VirtualMachineNetworkInterfaceArgs;
import com.pulumi.vsphere.inputs.VirtualMachineDiskArgs;
import com.pulumi.vsphere.ComputeClusterVmGroup;
import com.pulumi.vsphere.ComputeClusterVmGroupArgs;
import com.pulumi.vsphere.ComputeClusterHostGroup;
import com.pulumi.vsphere.ComputeClusterHostGroupArgs;
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 datastore = VsphereFunctions.getDatastore(GetDatastoreArgs.builder()
            .name("datastore1")
            .datacenterId(datacenter.id())
            .build());

        final var cluster = VsphereFunctions.getComputeCluster(GetComputeClusterArgs.builder()
            .name("cluster-01")
            .datacenterId(datacenter.id())
            .build());

        final var host = VsphereFunctions.getHost(GetHostArgs.builder()
            .name("esxi-01.example.com")
            .datacenterId(datacenter.id())
            .build());

        final var network = VsphereFunctions.getNetwork(GetNetworkArgs.builder()
            .name("network1")
            .datacenterId(datacenter.id())
            .build());

        var vm = new VirtualMachine("vm", VirtualMachineArgs.builder()
            .name("test")
            .resourcePoolId(cluster.resourcePoolId())
            .datastoreId(datastore.id())
            .numCpus(2)
            .memory(2048)
            .guestId("otherLinux64Guest")
            .networkInterfaces(VirtualMachineNetworkInterfaceArgs.builder()
                .networkId(network.id())
                .build())
            .disks(VirtualMachineDiskArgs.builder()
                .label("disk0")
                .size(20)
                .build())
            .build());

        var clusterVmGroup = new ComputeClusterVmGroup("clusterVmGroup", ComputeClusterVmGroupArgs.builder()
            .name("test-cluster-vm-group")
            .computeClusterId(cluster.id())
            .virtualMachineIds(vm.id())
            .build());

        var clusterHostGroup = new ComputeClusterHostGroup("clusterHostGroup", ComputeClusterHostGroupArgs.builder()
            .name("test-cluster-vm-group")
            .computeClusterId(cluster.id())
            .hostSystemIds(host.id())
            .build());

        var clusterVmHostRule = new ComputeClusterVmHostRule("clusterVmHostRule", ComputeClusterVmHostRuleArgs.builder()
            .computeClusterId(cluster.id())
            .name("test-cluster-vm-host-rule")
            .vmGroupName(clusterVmGroup.name())
            .affinityHostGroupName(clusterHostGroup.name())
            .build());

    }
}
Copy
resources:
  vm:
    type: vsphere:VirtualMachine
    properties:
      name: test
      resourcePoolId: ${cluster.resourcePoolId}
      datastoreId: ${datastore.id}
      numCpus: 2
      memory: 2048
      guestId: otherLinux64Guest
      networkInterfaces:
        - networkId: ${network.id}
      disks:
        - label: disk0
          size: 20
  clusterVmGroup:
    type: vsphere:ComputeClusterVmGroup
    name: cluster_vm_group
    properties:
      name: test-cluster-vm-group
      computeClusterId: ${cluster.id}
      virtualMachineIds:
        - ${vm.id}
  clusterHostGroup:
    type: vsphere:ComputeClusterHostGroup
    name: cluster_host_group
    properties:
      name: test-cluster-vm-group
      computeClusterId: ${cluster.id}
      hostSystemIds:
        - ${host.id}
  clusterVmHostRule:
    type: vsphere:ComputeClusterVmHostRule
    name: cluster_vm_host_rule
    properties:
      computeClusterId: ${cluster.id}
      name: test-cluster-vm-host-rule
      vmGroupName: ${clusterVmGroup.name}
      affinityHostGroupName: ${clusterHostGroup.name}
variables:
  datacenter:
    fn::invoke:
      function: vsphere:getDatacenter
      arguments:
        name: dc-01
  datastore:
    fn::invoke:
      function: vsphere:getDatastore
      arguments:
        name: datastore1
        datacenterId: ${datacenter.id}
  cluster:
    fn::invoke:
      function: vsphere:getComputeCluster
      arguments:
        name: cluster-01
        datacenterId: ${datacenter.id}
  host:
    fn::invoke:
      function: vsphere:getHost
      arguments:
        name: esxi-01.example.com
        datacenterId: ${datacenter.id}
  network:
    fn::invoke:
      function: vsphere:getNetwork
      arguments:
        name: network1
        datacenterId: ${datacenter.id}
Copy

Create ComputeClusterVmHostRule Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new ComputeClusterVmHostRule(name: string, args: ComputeClusterVmHostRuleArgs, opts?: CustomResourceOptions);
@overload
def ComputeClusterVmHostRule(resource_name: str,
                             args: ComputeClusterVmHostRuleArgs,
                             opts: Optional[ResourceOptions] = None)

@overload
def ComputeClusterVmHostRule(resource_name: str,
                             opts: Optional[ResourceOptions] = None,
                             compute_cluster_id: Optional[str] = None,
                             vm_group_name: Optional[str] = None,
                             affinity_host_group_name: Optional[str] = None,
                             anti_affinity_host_group_name: Optional[str] = None,
                             enabled: Optional[bool] = None,
                             mandatory: Optional[bool] = None,
                             name: Optional[str] = None)
func NewComputeClusterVmHostRule(ctx *Context, name string, args ComputeClusterVmHostRuleArgs, opts ...ResourceOption) (*ComputeClusterVmHostRule, error)
public ComputeClusterVmHostRule(string name, ComputeClusterVmHostRuleArgs args, CustomResourceOptions? opts = null)
public ComputeClusterVmHostRule(String name, ComputeClusterVmHostRuleArgs args)
public ComputeClusterVmHostRule(String name, ComputeClusterVmHostRuleArgs args, CustomResourceOptions options)
type: vsphere:ComputeClusterVmHostRule
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. ComputeClusterVmHostRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. ComputeClusterVmHostRuleArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. ComputeClusterVmHostRuleArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. ComputeClusterVmHostRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. ComputeClusterVmHostRuleArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var computeClusterVmHostRuleResource = new VSphere.ComputeClusterVmHostRule("computeClusterVmHostRuleResource", new()
{
    ComputeClusterId = "string",
    VmGroupName = "string",
    AffinityHostGroupName = "string",
    AntiAffinityHostGroupName = "string",
    Enabled = false,
    Mandatory = false,
    Name = "string",
});
Copy
example, err := vsphere.NewComputeClusterVmHostRule(ctx, "computeClusterVmHostRuleResource", &vsphere.ComputeClusterVmHostRuleArgs{
	ComputeClusterId:          pulumi.String("string"),
	VmGroupName:               pulumi.String("string"),
	AffinityHostGroupName:     pulumi.String("string"),
	AntiAffinityHostGroupName: pulumi.String("string"),
	Enabled:                   pulumi.Bool(false),
	Mandatory:                 pulumi.Bool(false),
	Name:                      pulumi.String("string"),
})
Copy
var computeClusterVmHostRuleResource = new ComputeClusterVmHostRule("computeClusterVmHostRuleResource", ComputeClusterVmHostRuleArgs.builder()
    .computeClusterId("string")
    .vmGroupName("string")
    .affinityHostGroupName("string")
    .antiAffinityHostGroupName("string")
    .enabled(false)
    .mandatory(false)
    .name("string")
    .build());
Copy
compute_cluster_vm_host_rule_resource = vsphere.ComputeClusterVmHostRule("computeClusterVmHostRuleResource",
    compute_cluster_id="string",
    vm_group_name="string",
    affinity_host_group_name="string",
    anti_affinity_host_group_name="string",
    enabled=False,
    mandatory=False,
    name="string")
Copy
const computeClusterVmHostRuleResource = new vsphere.ComputeClusterVmHostRule("computeClusterVmHostRuleResource", {
    computeClusterId: "string",
    vmGroupName: "string",
    affinityHostGroupName: "string",
    antiAffinityHostGroupName: "string",
    enabled: false,
    mandatory: false,
    name: "string",
});
Copy
type: vsphere:ComputeClusterVmHostRule
properties:
    affinityHostGroupName: string
    antiAffinityHostGroupName: string
    computeClusterId: string
    enabled: false
    mandatory: false
    name: string
    vmGroupName: string
Copy

ComputeClusterVmHostRule Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The ComputeClusterVmHostRule resource accepts the following input properties:

ComputeClusterId
This property is required.
Changes to this property will trigger replacement.
string
The managed object reference ID of the cluster to put the group in. Forces a new resource if changed.
VmGroupName This property is required. string
The name of the virtual machine group to use with this rule.
AffinityHostGroupName string
When this field is used, the virtual machines defined in vm_group_name will be run on the hosts defined in this host group.
AntiAffinityHostGroupName string
When this field is used, the virtual machines defined in vm_group_name will not be run on the hosts defined in this host group.
Enabled bool
Enable this rule in the cluster. Default: true.
Mandatory bool

When this value is true, prevents any virtual machine operations that may violate this rule. Default: false.

NOTE: One of affinity_host_group_name or anti_affinity_host_group_name must be defined, but not both.

NOTE: The namespace for rule names on this resource (defined by the name argument) is shared with all rules in the cluster - consider this when naming your rules.

Name string
The name of the rule. This must be unique in the cluster.
ComputeClusterId
This property is required.
Changes to this property will trigger replacement.
string
The managed object reference ID of the cluster to put the group in. Forces a new resource if changed.
VmGroupName This property is required. string
The name of the virtual machine group to use with this rule.
AffinityHostGroupName string
When this field is used, the virtual machines defined in vm_group_name will be run on the hosts defined in this host group.
AntiAffinityHostGroupName string
When this field is used, the virtual machines defined in vm_group_name will not be run on the hosts defined in this host group.
Enabled bool
Enable this rule in the cluster. Default: true.
Mandatory bool

When this value is true, prevents any virtual machine operations that may violate this rule. Default: false.

NOTE: One of affinity_host_group_name or anti_affinity_host_group_name must be defined, but not both.

NOTE: The namespace for rule names on this resource (defined by the name argument) is shared with all rules in the cluster - consider this when naming your rules.

Name string
The name of the rule. This must be unique in the cluster.
computeClusterId
This property is required.
Changes to this property will trigger replacement.
String
The managed object reference ID of the cluster to put the group in. Forces a new resource if changed.
vmGroupName This property is required. String
The name of the virtual machine group to use with this rule.
affinityHostGroupName String
When this field is used, the virtual machines defined in vm_group_name will be run on the hosts defined in this host group.
antiAffinityHostGroupName String
When this field is used, the virtual machines defined in vm_group_name will not be run on the hosts defined in this host group.
enabled Boolean
Enable this rule in the cluster. Default: true.
mandatory Boolean

When this value is true, prevents any virtual machine operations that may violate this rule. Default: false.

NOTE: One of affinity_host_group_name or anti_affinity_host_group_name must be defined, but not both.

NOTE: The namespace for rule names on this resource (defined by the name argument) is shared with all rules in the cluster - consider this when naming your rules.

name String
The name of the rule. This must be unique in the cluster.
computeClusterId
This property is required.
Changes to this property will trigger replacement.
string
The managed object reference ID of the cluster to put the group in. Forces a new resource if changed.
vmGroupName This property is required. string
The name of the virtual machine group to use with this rule.
affinityHostGroupName string
When this field is used, the virtual machines defined in vm_group_name will be run on the hosts defined in this host group.
antiAffinityHostGroupName string
When this field is used, the virtual machines defined in vm_group_name will not be run on the hosts defined in this host group.
enabled boolean
Enable this rule in the cluster. Default: true.
mandatory boolean

When this value is true, prevents any virtual machine operations that may violate this rule. Default: false.

NOTE: One of affinity_host_group_name or anti_affinity_host_group_name must be defined, but not both.

NOTE: The namespace for rule names on this resource (defined by the name argument) is shared with all rules in the cluster - consider this when naming your rules.

name string
The name of the rule. This must be unique in the cluster.
compute_cluster_id
This property is required.
Changes to this property will trigger replacement.
str
The managed object reference ID of the cluster to put the group in. Forces a new resource if changed.
vm_group_name This property is required. str
The name of the virtual machine group to use with this rule.
affinity_host_group_name str
When this field is used, the virtual machines defined in vm_group_name will be run on the hosts defined in this host group.
anti_affinity_host_group_name str
When this field is used, the virtual machines defined in vm_group_name will not be run on the hosts defined in this host group.
enabled bool
Enable this rule in the cluster. Default: true.
mandatory bool

When this value is true, prevents any virtual machine operations that may violate this rule. Default: false.

NOTE: One of affinity_host_group_name or anti_affinity_host_group_name must be defined, but not both.

NOTE: The namespace for rule names on this resource (defined by the name argument) is shared with all rules in the cluster - consider this when naming your rules.

name str
The name of the rule. This must be unique in the cluster.
computeClusterId
This property is required.
Changes to this property will trigger replacement.
String
The managed object reference ID of the cluster to put the group in. Forces a new resource if changed.
vmGroupName This property is required. String
The name of the virtual machine group to use with this rule.
affinityHostGroupName String
When this field is used, the virtual machines defined in vm_group_name will be run on the hosts defined in this host group.
antiAffinityHostGroupName String
When this field is used, the virtual machines defined in vm_group_name will not be run on the hosts defined in this host group.
enabled Boolean
Enable this rule in the cluster. Default: true.
mandatory Boolean

When this value is true, prevents any virtual machine operations that may violate this rule. Default: false.

NOTE: One of affinity_host_group_name or anti_affinity_host_group_name must be defined, but not both.

NOTE: The namespace for rule names on this resource (defined by the name argument) is shared with all rules in the cluster - consider this when naming your rules.

name String
The name of the rule. This must be unique in the cluster.

Outputs

All input properties are implicitly available as output properties. Additionally, the ComputeClusterVmHostRule resource produces the following output properties:

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

Look up Existing ComputeClusterVmHostRule Resource

Get an existing ComputeClusterVmHostRule resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: ComputeClusterVmHostRuleState, opts?: CustomResourceOptions): ComputeClusterVmHostRule
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        affinity_host_group_name: Optional[str] = None,
        anti_affinity_host_group_name: Optional[str] = None,
        compute_cluster_id: Optional[str] = None,
        enabled: Optional[bool] = None,
        mandatory: Optional[bool] = None,
        name: Optional[str] = None,
        vm_group_name: Optional[str] = None) -> ComputeClusterVmHostRule
func GetComputeClusterVmHostRule(ctx *Context, name string, id IDInput, state *ComputeClusterVmHostRuleState, opts ...ResourceOption) (*ComputeClusterVmHostRule, error)
public static ComputeClusterVmHostRule Get(string name, Input<string> id, ComputeClusterVmHostRuleState? state, CustomResourceOptions? opts = null)
public static ComputeClusterVmHostRule get(String name, Output<String> id, ComputeClusterVmHostRuleState state, CustomResourceOptions options)
resources:  _:    type: vsphere:ComputeClusterVmHostRule    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
AffinityHostGroupName string
When this field is used, the virtual machines defined in vm_group_name will be run on the hosts defined in this host group.
AntiAffinityHostGroupName string
When this field is used, the virtual machines defined in vm_group_name will not be run on the hosts defined in this host group.
ComputeClusterId Changes to this property will trigger replacement. string
The managed object reference ID of the cluster to put the group in. Forces a new resource if changed.
Enabled bool
Enable this rule in the cluster. Default: true.
Mandatory bool

When this value is true, prevents any virtual machine operations that may violate this rule. Default: false.

NOTE: One of affinity_host_group_name or anti_affinity_host_group_name must be defined, but not both.

NOTE: The namespace for rule names on this resource (defined by the name argument) is shared with all rules in the cluster - consider this when naming your rules.

Name string
The name of the rule. This must be unique in the cluster.
VmGroupName string
The name of the virtual machine group to use with this rule.
AffinityHostGroupName string
When this field is used, the virtual machines defined in vm_group_name will be run on the hosts defined in this host group.
AntiAffinityHostGroupName string
When this field is used, the virtual machines defined in vm_group_name will not be run on the hosts defined in this host group.
ComputeClusterId Changes to this property will trigger replacement. string
The managed object reference ID of the cluster to put the group in. Forces a new resource if changed.
Enabled bool
Enable this rule in the cluster. Default: true.
Mandatory bool

When this value is true, prevents any virtual machine operations that may violate this rule. Default: false.

NOTE: One of affinity_host_group_name or anti_affinity_host_group_name must be defined, but not both.

NOTE: The namespace for rule names on this resource (defined by the name argument) is shared with all rules in the cluster - consider this when naming your rules.

Name string
The name of the rule. This must be unique in the cluster.
VmGroupName string
The name of the virtual machine group to use with this rule.
affinityHostGroupName String
When this field is used, the virtual machines defined in vm_group_name will be run on the hosts defined in this host group.
antiAffinityHostGroupName String
When this field is used, the virtual machines defined in vm_group_name will not be run on the hosts defined in this host group.
computeClusterId Changes to this property will trigger replacement. String
The managed object reference ID of the cluster to put the group in. Forces a new resource if changed.
enabled Boolean
Enable this rule in the cluster. Default: true.
mandatory Boolean

When this value is true, prevents any virtual machine operations that may violate this rule. Default: false.

NOTE: One of affinity_host_group_name or anti_affinity_host_group_name must be defined, but not both.

NOTE: The namespace for rule names on this resource (defined by the name argument) is shared with all rules in the cluster - consider this when naming your rules.

name String
The name of the rule. This must be unique in the cluster.
vmGroupName String
The name of the virtual machine group to use with this rule.
affinityHostGroupName string
When this field is used, the virtual machines defined in vm_group_name will be run on the hosts defined in this host group.
antiAffinityHostGroupName string
When this field is used, the virtual machines defined in vm_group_name will not be run on the hosts defined in this host group.
computeClusterId Changes to this property will trigger replacement. string
The managed object reference ID of the cluster to put the group in. Forces a new resource if changed.
enabled boolean
Enable this rule in the cluster. Default: true.
mandatory boolean

When this value is true, prevents any virtual machine operations that may violate this rule. Default: false.

NOTE: One of affinity_host_group_name or anti_affinity_host_group_name must be defined, but not both.

NOTE: The namespace for rule names on this resource (defined by the name argument) is shared with all rules in the cluster - consider this when naming your rules.

name string
The name of the rule. This must be unique in the cluster.
vmGroupName string
The name of the virtual machine group to use with this rule.
affinity_host_group_name str
When this field is used, the virtual machines defined in vm_group_name will be run on the hosts defined in this host group.
anti_affinity_host_group_name str
When this field is used, the virtual machines defined in vm_group_name will not be run on the hosts defined in this host group.
compute_cluster_id Changes to this property will trigger replacement. str
The managed object reference ID of the cluster to put the group in. Forces a new resource if changed.
enabled bool
Enable this rule in the cluster. Default: true.
mandatory bool

When this value is true, prevents any virtual machine operations that may violate this rule. Default: false.

NOTE: One of affinity_host_group_name or anti_affinity_host_group_name must be defined, but not both.

NOTE: The namespace for rule names on this resource (defined by the name argument) is shared with all rules in the cluster - consider this when naming your rules.

name str
The name of the rule. This must be unique in the cluster.
vm_group_name str
The name of the virtual machine group to use with this rule.
affinityHostGroupName String
When this field is used, the virtual machines defined in vm_group_name will be run on the hosts defined in this host group.
antiAffinityHostGroupName String
When this field is used, the virtual machines defined in vm_group_name will not be run on the hosts defined in this host group.
computeClusterId Changes to this property will trigger replacement. String
The managed object reference ID of the cluster to put the group in. Forces a new resource if changed.
enabled Boolean
Enable this rule in the cluster. Default: true.
mandatory Boolean

When this value is true, prevents any virtual machine operations that may violate this rule. Default: false.

NOTE: One of affinity_host_group_name or anti_affinity_host_group_name must be defined, but not both.

NOTE: The namespace for rule names on this resource (defined by the name argument) is shared with all rules in the cluster - consider this when naming your rules.

name String
The name of the rule. This must be unique in the cluster.
vmGroupName String
The name of the virtual machine group to use with this rule.

Import

An existing rule can be imported into this resource by supplying

both the path to the cluster, and the name the rule. If the name or cluster is

not found, or if the rule is of a different type, an error will be returned. An

example is below:

$ pulumi import vsphere:index/computeClusterVmHostRule:ComputeClusterVmHostRule cluster_vm_host_rule \
Copy

‘{“compute_cluster_path”: “/dc1/host/cluster1”, \

“name”: “pulumi-test-cluster-vm-host-rule”}’

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
vSphere pulumi/pulumi-vsphere
License
Apache-2.0
Notes
This Pulumi package is based on the vsphere Terraform Provider.