The vsphere_host data source can be used to discover the ID of a vSphere host. This can then be used with resources or data sources that require a host managed object reference ID.
data "vsphere_datacenter" "datacenter" {
name = "dc1"
}
data "vsphere_host" "host" {
name = "esxi1"
datacenter_id = "${data.vsphere_datacenter.datacenter.id}"
}
The following arguments are supported:
datacenter_id - (Required) The managed object reference ID of a datacenter. name - (Optional) The name of the host. This can be a name or path. Can be omitted if there is only one host in your inventory. NOTE: When used against an ESXi host directly, this data source always fetches the server's host object ID, regardless of what is entered into
name.
id - The managed objectID of this host. resource_pool_id - The managed object ID of the host's root resource pool. Note that the resource pool referenced by
resource_pool_idis dependent on the target host's state - if it's a standalone host, the resource pool will belong to the host only, however if it is a member of a cluster, the resource pool will be the root for the entire cluster.
© 2018 HashiCorpLicensed under the MPL 2.0 License.
https://www.terraform.io/docs/providers/vsphere/d/host.html