Last active
June 8, 2022 19:04
-
-
Save rafaelfuchsbr/c9653d591ac50250834fa0e638203c67 to your computer and use it in GitHub Desktop.
Terraform maps matching
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
locals { | |
a = { | |
"key1" = "valueX" | |
"key2" = "valueY" | |
"key3" = "valueZ" | |
} | |
b = { | |
"key1" = "valueA" | |
"key2" = "valueB" | |
"key3" = "valueC" | |
} | |
c = merge([ | |
for ka,va in local.a : { | |
for kb,vb in local.b: va => vb if ka == kb | |
} | |
]...) | |
} | |
output "c" { | |
value = local.c | |
} |
The Terraform language has a general feature for turning lists/tuples into multiple arguments, by using the special symbol ... after the last argument expression
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: