Adding multiple VLAN in vsphere using calling code

Hello All,

Am using module and calling codes method to build the infra and which is working perfectly alright. Now am trying to add multiple servers using calling code and adding multiple VLAN’s for one of the servers. Have tried some method using for_each, but it’s not working. Could someone help me in this?

Module: (Updated only the relevant lines)

...

data "vsphere_network" "network" {
  count         = length(var.generic_vm_type)
  name          = "${lookup(var.generic_vm_type[count.index], "network_name")}"
  datacenter_id = data.vsphere_datacenter.dc.id
}
data "vsphere_virtual_machine" "template" {
  count         = length(var.generic_vm_type)
  name          = "${lookup(var.generic_vm_type[count.index], "template_name")}"
  datacenter_id = data.vsphere_datacenter.dc.id
}
...
network_interface {
    network_id   = data.vsphere_network.network[count.index].id
    adapter_type = data.vsphere_virtual_machine.template[count.index].network_interface_types[0]
  }
...
customize {
      linux_options {
        host_name = "${var.vsphere_env}-${var.project_name}-${var.generic_vm_type[count.index].name}"
        domain    = var.vsphere_domain
        time_zone = var.vsphere_time_zone
      }

      network_interface {
        ipv4_address = cidrhost(var.generic_vm_type[count.index].ip_cidr, var.generic_vm_type[count.index].ip_start)
        ipv4_netmask = element(split("/", var.generic_vm_type[count.index].ip_cidr), 1)
      }

      ipv4_gateway = var.generic_vm_type[count.index].network_gw
    }

In calling code: (Updated only the relevant files)

locals {
  generic_vm_type = [
    {
      name          = "server"
      template_name = "centos7"
      ip_cidr       = "10.1.7.20/24"
      ip_start      = "20"
      network_gw    = "10.1.7.1"
      network_name = "vlan7"
    },
    {
      name          = "client"
      template_name = "centos7"
      ip_cidr       = "10.1.2.25/24"
      ip_start      = "25"
      network_gw    ="10.1.2.1"
      network_name  = "vlan2"
    },
  ]
}

I want to add two VLAN’s (for example vlan2 and vlan3) only to the client. Any suggestions?

This has been done.
Have followed https://github.com/Terraform-VMWare-Modules/terraform-vsphere-vm