» vsphere_compute_cluster_host_group

The vsphere_compute_cluster_host_group resource can be used to manage groups of hosts in a cluster, either created by the vsphere_compute_cluster resource or looked up by the vsphere_compute_cluster data source.

This resource mainly serves as an input to the vsphere_compute_cluster_vm_host_rule resource - see the documentation for that resource for further details on how to use host groups.

» Example Usage

The example below is the exact same configuration as the example in the vsphere_compute_cluster resource, but in addition, it creates a host group with the same hosts that get put into the cluster.

variable "datacenter" {
  default = "dc1"

variable "hosts" {
  default = [

data "vsphere_datacenter" "dc" {
  name = "${var.datacenter}"

data "vsphere_host" "hosts" {
  count         = "${length(var.hosts)}"
  name          = "${var.hosts[count.index]}"
  datacenter_id = "${data.vsphere_datacenter.dc.id}"

resource "vsphere_compute_cluster" "compute_cluster" {
  name            = "terraform-compute-cluster-test"
  datacenter_id   = "${data.vsphere_datacenter.dc.id}"
  host_system_ids = ["${data.vsphere_host.hosts.*.id}"]

  drs_enabled          = true
  drs_automation_level = "fullyAutomated"

  ha_enabled = true

resource "vsphere_compute_cluster_host_group" "cluster_host_group" {
  name               = "terraform-test-cluster-host-group"
  compute_cluster_id = "${vsphere_compute_cluster.compute_cluster.id}"
  host_system_ids    = ["${data.vsphere_host.hosts.*.id}"]

» Argument Reference

The following arguments are supported:

» Attribute Reference

The only attribute this resource exports is the id of the resource, which is a combination of the managed object reference ID of the cluster, and the name of the host group.

» Importing

An existing group can be imported into this resource by supplying both the path to the cluster, and the name of the host group. If the name or cluster is not found, or if the group is of a different type, an error will be returned. An example is below:

terraform import vsphere_compute_cluster_host_group.cluster_host_group \
  '{"compute_cluster_path": "/dc1/host/cluster1", \
  "name": "terraform-test-cluster-host-group"}'