Created
January 12, 2021 08:40
-
-
Save alastairhm/6fae1a50a9c96b2e3bd275ccb2584d72 to your computer and use it in GitHub Desktop.
Terraform extracting a list of values from a map of maps
This file contains 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 "node_private_ips" { | |
default = { | |
"node1" = { | |
"az" = "eu-west-1a" | |
"fqdn" = "vadc-ext-pres-node1.ccoe-ch.aws-eu-west-1.dev.fred.plc" | |
"ip" = "100.77.254.5" | |
} | |
"node2" = { | |
"az" = "eu-west-1b" | |
"fqdn" = "vadc-ext-pres-node2.ccoe-ch.aws-eu-west-1.dev.fred.plc" | |
"ip" = "100.77.254.69" | |
} | |
"node3" = { | |
"az" = "eu-west-1c" | |
"fqdn" = "vadc-ext-pres-node3.ccoe-ch.aws-eu-west-1.dev.fred.plc" | |
"ip" = "100.77.254.133" | |
} | |
} | |
} | |
output "maps" { | |
value = var.node_private_ips | |
} | |
output "values" { | |
value = values(var.node_private_ips) | |
} | |
output "ips" { | |
value = [for value in values(var.node_private_ips): value["ip"]] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment