terraform/website/docs/language/functions/setsubtract.html.md

1.1 KiB

layout page_title sidebar_current description
language setsubtract - Functions - Configuration Language docs-funcs-collection-setsubtract The setsubtract function returns a new set containing the elements from the first set that are not present in the second set

setsubtract Function

The setsubtract function returns a new set containing the elements from the first set that are not present in the second set. In other words, it computes the relative complement of the second set in the first set.

setsubtract(a, b)

Examples

> setsubtract(["a", "b", "c"], ["a", "c"])
[
  "b",
]

Set Difference (Symmetric Difference)

> setunion(setsubtract(["a", "b", "c"], ["a", "c", "d"]), setsubtract(["a", "c", "d"], ["a", "b", "c"]))
[
  "b",
  "d",
]
  • setintersection computes the intersection of multiple sets
  • setproduct computes the Cartesian product of multiple sets.
  • setunion computes the union of multiple sets.