Terraform
setsubtract Function
⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
[!IMPORTANT]
Documentation Update: Product documentation previously located in/website
has moved to thehashicorp/web-unified-docs
repository, where all product documentation is now centralized. Please make contributions directly toweb-unified-docs
, since changes to/website
in this repository will not appear on developer.hashicorp.com. ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
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.
setsubtract(a, b)
Examples
> setsubtract(["a", "b", "c"], ["a", "c"])
toset([
"b",
])
Set Difference (Symmetric Difference)
> setunion(setsubtract(["a", "b", "c"], ["a", "c", "d"]), setsubtract(["a", "c", "d"], ["a", "b", "c"]))
toset([
"b",
"d",
])
Related Functions
setintersection
computes the intersection of multiple setssetproduct
computes the Cartesian product of multiple sets.setunion
computes the union of multiple sets.