Adding host to DVS

I have the following terraform code:

data "vsphere_host" "host" {
  name          = var.ENVIRONMENT_CONTEXT__VARIABLES__HOST
  datacenter_id = "${data.vsphere_datacenter.dc.id}"
}
resource "vsphere_distributed_virtual_switch" "dvsa" {
  name          = "dspah"
  datacenter_id = "${data.vsphere_datacenter.dc.id}"

  uplinks         = ["tfup1"]
  active_uplinks  = ["tfup1"]
  
  host {
     host_system_id = "${data.vsphere_host.host.id}"
     //devices        = ["${var.network_interfaces}"]
     devices        = ["vmnic0","vmnic1"]
  }
}

After terraform apply I get the following error:

╷
│ Error: error waiting for DVS creation to complete: The operation is not supported on the object.
│ 
│   with vsphere_distributed_virtual_switch.dvsa,
│   on main.tf line 76, in resource "vsphere_distributed_virtual_switch" "dvsa":
│   76: resource "vsphere_distributed_virtual_switch" "dvsa" {
│ 
╵

When I comment my host block , my error will be solved.

I need to introduce my ESXI to my DVS. It has a permanet IP address.
How can I introduce it?

NOTE: I do not want to create ESXI, I have it. I only want to introduce it.

I notice the same thing,I think this can be solved with a depends_on

1 Like