Created
August 12, 2019 23:01
-
-
Save RulerOf/5401b6d5be8302020921442200479a62 to your computer and use it in GitHub Desktop.
Turning two lists of maps into a single map output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "map1" { | |
default = [ | |
{ | |
name = "map1name1", | |
default_ip_address = "map1addr1" | |
}, | |
{ | |
name = "map1name2", | |
default_ip_address = "map1addr2" | |
} | |
] | |
} | |
variable "map2" { | |
default = [ | |
{ | |
name = "map2name1", | |
default_ip_address = "map2addr1" | |
}, | |
{ | |
name = "map2name2", | |
default_ip_address = "map2addr2" | |
} | |
] | |
} | |
locals { | |
servers = zipmap( | |
concat( | |
var.map1.*.name, | |
var.map2.*.name | |
), | |
concat( | |
var.map1.*.default_ip_address, | |
var.map2.*.default_ip_address | |
) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment