-
Notifications
You must be signed in to change notification settings - Fork 478
Description
Description
Suppose you'd like to bootstrap your vCenter environment in Terraform. This may include finding all data stores that meet specific criteria, e.g. ends with "-data" and tag them as a data disk. The current vsphere_datastore data source requires that you specify a name, which implies that you have to know all data sources upfront.
Introduce the plural of data sources, e.g. vsphere_datastores which returns all the data stores for a specific data center, host, cluster, and whatnot.
Potential Terraform Configuration
Datastores in Data Centers
To return all data stores for a data center:
data "vsphere_datacenter" "dc" {
name = "Example"
}
data "vsphere_datastores" "dc" {
datacenter_id = data.vsphere_datacenter.dc.id
}This would be the equivalent of going to vCenter, selecting the data center in question, and returning all the items in the "Datastores" tab.
Datastores in Hosts
To return all data stores of a host:
data "vsphere_datacenter" "main" {
name = "Example"
}
data "vsphere_host" "main" {
name = "esxi1"
datacenter_id = data.vsphere_datacenter.main.id
}
data "vsphere_datastores" "main" {
host_id = data. vsphere_host.main.id
}This would be the equivalent of going to vCenter, selecting the host in question, and returning all the items in the "Datastores" tab.
The same pattern can be applied to any vSphere resource that has a data store. For each datastore, do return the datacenter, hosts, and whatnot that references it. This would be the equivalent of the properties when viewing a datastore in vCenter. One can see the hosts, VMS, devices backing it, and so forth.
References
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment