github.com/muratcelep/terraform@v1.1.0-beta2-not-internal-4/website/docs/language/functions/setintersection.html.md (about) 1 --- 2 layout: "language" 3 page_title: "setintersection - Functions - Configuration Language" 4 sidebar_current: "docs-funcs-collection-setintersection" 5 description: |- 6 The setintersection function takes multiple sets and produces a single set 7 containing only the elements that all of the given sets have in common. 8 --- 9 10 # `setintersection` Function 11 12 The `setintersection` function takes multiple sets and produces a single set 13 containing only the elements that all of the given sets have in common. 14 In other words, it computes the 15 [intersection](https://en.wikipedia.org/wiki/Intersection_(set_theory)) of the sets. 16 17 ```hcl 18 setintersection(sets...) 19 ``` 20 21 ## Examples 22 23 ``` 24 > setintersection(["a", "b"], ["b", "c"], ["b", "d"]) 25 [ 26 "b", 27 ] 28 ``` 29 30 The given arguments are converted to sets, so the result is also a set and 31 the ordering of the given elements is not preserved. 32 33 ## Related Functions 34 35 * [`contains`](./contains.html) tests whether a given list or set contains 36 a given element value. 37 * [`setproduct`](./setproduct.html) computes the _Cartesian product_ of multiple 38 sets. 39 * [`setsubtract`](./setsubtract.html) computes the _relative complement_ of two sets 40 * [`setunion`](./setunion.html) computes the _union_ of 41 multiple sets.