Skip to content

Instantly share code, notes, and snippets.

@alastairhm
Created January 12, 2021 08:40
Show Gist options
  • Save alastairhm/6fae1a50a9c96b2e3bd275ccb2584d72 to your computer and use it in GitHub Desktop.
Save alastairhm/6fae1a50a9c96b2e3bd275ccb2584d72 to your computer and use it in GitHub Desktop.
Terraform extracting a list of values from a map of maps
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