You can use terraform setintersection() function to get only the common values between multiple sets. The setintersection() function takes multiple sets and produces a single set containing only the elements that all of the given sets have in common. In other words, it computes the intersection of the sets.
Syntax: setintersection(set1, set2, …)
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
## Open terraform console terraform console ## Get common values from multiple sets setintersection(["a", "b"], ["b", "c"], ["b", "d"]) ## returns ## [ ## "b", ## ] setintersection(["a", "b"], ["b", "c"], ["c", "d"]) ## returns ## [] |