» vsphere_compute_cluster_vm_group

The vsphere_compute_cluster_vm_group resource can be used to manage groups of virtual machines 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_dependency_rule and vsphere_compute_cluster_vm_host_rule resources. See the individual resource documentation pages for more information.

» Example Usage

The example below creates two virtual machines in a cluster using the vsphere_virtual_machine resource, creating the virtual machine in the cluster looked up by the vsphere_compute_cluster data source. It then creates a group from these two virtual machines.

data "vsphere_datacenter" "dc" {
  name = "dc1"
}

data "vsphere_datastore" "datastore" {
  name          = "datastore1"
  datacenter_id = "${data.vsphere_datacenter.dc.id}"
}

data "vsphere_compute_cluster" "cluster" {
  name          = "cluster1"
  datacenter_id = "${data.vsphere_datacenter.dc.id}"
}

data "vsphere_network" "network" {
  name          = "network1"
  datacenter_id = "${data.vsphere_datacenter.dc.id}"
}

resource "vsphere_virtual_machine" "vm" {
  count            = 2
  name             = "terraform-test-${count.index}"
  resource_pool_id = "${data.vsphere_compute_cluster.cluster.resource_pool_id}"
  datastore_id     = "${data.vsphere_datastore.datastore.id}"

  num_cpus = 2
  memory   = 2048
  guest_id = "other3xLinux64Guest"

  network_interface {
    network_id = "${data.vsphere_network.network.id}"
  }

  disk {
    label = "disk0"
    size  = 20
  }
}

resource "vsphere_compute_cluster_vm_group" "cluster_vm_group" {
  name                = "terraform-test-cluster-vm-group"
  compute_cluster_id  = "${data.vsphere_compute_cluster.cluster.id}"
  virtual_machine_ids = ["${vsphere_virtual_machine.vm.*.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 virtual machine group.

» Importing

An existing group can be imported into this resource by supplying both the path to the cluster, and the name of the VM 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_vm_group.cluster_vm_group \
  '{"compute_cluster_path": "/dc1/host/cluster1", \
  "name": "terraform-test-cluster-vm-group"}'