Need help constructing a map from lists

Hi, we have the following lists:

var.additional_company_com_dns_names
local.dns_company_com_public_subdomain

We are currently creating a list from them like so:

  additional_public_company_com_dns_fqdns = flatten([
    for name in var.additional_company_com_dns_names : [
      for subdomain in local.dns_company_com_public_subdomain :
      "${name}.${subdomain}"
    ]
  ])

We need to modify this logic to create a map where the resultant ${name}.${subdomain} from the above is the key and the subdomain is the value.

Help would be appreciated!

Took some time away from the kb and solved it. Kind of embarassing how simple it was in the end.

  map_of_company_com_dns_fqdns = flatten([
    for name in var.additional_company_com_dns_names : [
      for subdomain in local.dns_company_com_public_subdomain : {
        "${name}.${subdomain}" = subdomain
    }]]
  )
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.