terraform-provider-vsphere
terraform-provider-vsphere copied to clipboard
Add support for a `vsphere_distributed_port_group` data source
Description
Although we have a resource for creating/manipulating a new distributed port group, there is no data source for retrieving a current distributed port group. This is challenging when attempting to use other resources (e.g. vsphere_entity_permissions
) - requiring the end user to find the mo-ref/entity id manually.
The data resource would require a parent distributed virtual switch id and a port group name (used for searching/filtering distributed port groups). For brevity, I chose dvs_id
but that could easily be virtualswitch_id
or something else that's more robust.
Potential Terraform Configuration
data "vsphere_datacenter" "datacenter" {
name = "dc1"
}
data "vsphere_distributed_virtual_switch" "dvs" {
name = "terraform-test-dvs"
datacenter_id = data.vsphere_datacenter.datacenter.id
}
data "vsphere_distributed_port_group" "my-dvpg" {
name = "terraform-test-dvpg"
dvs_id = data.vspherer_distributed_virtual_switch.dvs.id
}
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
To add colour to why this would be useful - We would like to start deploying VMs via Terraform in an environment which already contains distributed port groups. We currently would need to create a new dpg managed by Terraform or import the existing dpg to the state which is not an optimal way of doing this.