Portgroups and VM and their relation

I have PortGroup1 and VM1, I creating them via terraforem. Now, I need to tell VM1 for its network adapter have to member of PortGropup1. How can I do it via terraform?

Is this the same question?

resource "vsphere_virtual_machine" "pah-mgm" {
network_interface{
network_id = vsphere_distributed_port_group.pg-mgm.id
}

I get the following error:

╷
│ Error: error reconfiguring virtual machine: error reconfiguring virtual machine: A specified parameter was not correct: spec.deviceChange.device.port.switchUuid
│ 
│   with vsphere_virtual_machine.pah_majd,
│   on main.tf line 97, in resource "vsphere_virtual_machine" "pah_majd":
│   97: resource "vsphere_virtual_machine" "pah_majd" {
│ 
╵