VMware provider - custom_attributes dynamically generated

Hello,
It is possible to generate custom_attributes for resource vsphere_virtual_machine?

I’m trying to do the next thing:

variable "custom_attribute" {
 type = map(string)
  default = {
    "dns"     = "8.8.8.8,8.8.4.4"
    "fqdn"    = ""
    "gw"      = ""
    "ipaddr"  = ""
    "netmask" = ""
  }
}

resource "vsphere_custom_attribute" "attribute" {
  for_each            = var.custom_attribute

  name                = each.key
  managed_object_type = "VirtualMachine"
}

But I don’t know how to generate map… I’m trying todo like this:

locals {
  map_ca = {
    for key, value in var.custom_attribute :
      vsphere_custom_attribute.attribute[key].id = value
      if value != ""
  }
}

And use it in the resource:

resource "vsphere_virtual_machine" "cp_ca" {
  # ...

  custom_attributes = local.map_ca
}