A coworker had a challenge wanting to do a merge() on a list of maps:
list = [
{
keyA = {
subkey1 = "value1"
}
},
{
keyA = {
subkey2 = "value2"
}
},
{
keyB = {
subkey3 = "value3"
}
}
]
The issue is that merge() takes a list of maps and will only keep the value of the key from the last list element that contained it. Running merge(var.list...) results in:
merged_map = {
"keyA" = {
"subkey2" = "value2"
}
"keyB" = {
"subkey3" = "value3"
}
}
The desire was for the result to be:
combine_map = {
"keyA" = {
"subkey1" = "value1"
"subkey2" = "value2"
}
"keyB" = {
"subkey3" = "value3"
}
}
After spending some time transforming the data, the idea of a data-only module seemed useful, so I created a git repository with many of the bells and whistles and published the module:
