Hi all,
i would like to convert this input object variables
variable "my_tag" {
type = set(object({
namespace = string
tag = set(object({
name = string
value = string
cost = bool
}))
}))
}
to a map like this
variable "my_map_tag" {
type = map(string)
}
so this input:
my_tag = [{namespace = "Local", tag =[{ name = "CompanyId", value = "1111", cost = false }, { name = "Level", value = "222", cost = true }]},{namespace = "Remote", tag =[{ name = "Place", value = "none", cost = false }]}]
in
my_map_tag = { "Local.CompanyId" = "1111", "Local.Level"="222", "Remote".Place="none"}
i’ve try to define local like this:
locals {
my_tag = tolist([for v in [ for namespace in var.my_tag : { for tag in namespace.tag: join(".",[namespace.namespace,tag.name]) => tag.value} ]: tomap(v)])
}
but it doesn’t work.
Thanks,
K.