Skip to content

Instantly share code, notes, and snippets.

@ImIOImI
Created January 13, 2024 23:00
Show Gist options
  • Save ImIOImI/94a1d6cecc9145a41d8478c867095d0b to your computer and use it in GitHub Desktop.
Save ImIOImI/94a1d6cecc9145a41d8478c867095d0b to your computer and use it in GitHub Desktop.
Create a product of two maps
# I find myself having to get the product of two maps fairly regularly, this is one way to do it
locals {
pre_merge = [
for map1_key, map1_object in local.map1 : {
for map2_key, map2_value in local.map2 : "${map1_key}-${map2_key}" => {
map2_value_name = map2_value
object_name = object.name
object_id = object.id
}
}
]
links = merge(local.pre_merge...)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment