Closed pezhore closed 3 days ago
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.
so this was just write for vsphere_network to pull back the distribution or standard switch portgroup by network_type and name would it work for this problem? https://github.com/hashicorp/terraform-provider-vsphere/pull/2281
That might work? From my read of the Changelog on that PR, it would seem to cover my use case.
i updated it so it would look like this
data "vsphere_datacenter" "datacenter" {
name = "dc-01"
}
data "vsphere_network" "my_port_group" {
datacenter_id = data.vsphere_datacenter.datacenter.id
name = "VM Network"
network_type = "Network"
}
give it a run through, we can create a new data source with the same type code but did not know if this would work
yeah that should work for me.!
I had to make a couple changes to the code, once it is release it, i will close out this issue
This functionality has been released in v2.10.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.
For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!
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 bevirtualswitch_id
or something else that's more robust.Potential Terraform Configuration
References
Community Note