github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/configuration/functions/setintersection.html.md (about)

     1  ---
     2  layout: "functions"
     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  -> **Note:** This page is about Terraform 0.12 and later. For Terraform 0.11 and
    13  earlier, see
    14  [0.11 Configuration Language: Interpolation Syntax](../../configuration-0-11/interpolation.html).
    15  
    16  The `setintersection` function takes multiple sets and produces a single set
    17  containing only the elements that all of the given sets have in common.
    18  In other words, it computes the
    19  [intersection](https://en.wikipedia.org/wiki/Intersection_(set_theory)) of the sets.
    20  
    21  ```hcl
    22  setintersection(sets...)
    23  ```
    24  
    25  ## Examples
    26  
    27  ```
    28  > setintersection(["a", "b"], ["b", "c"], ["b", "d"])
    29  [
    30    "b",
    31  ]
    32  ```
    33  
    34  The given arguments are converted to sets, so the result is also a set and
    35  the ordering of the given elements is not preserved.
    36  
    37  ## Related Functions
    38  
    39  * [`contains`](./contains.html) tests whether a given list or set contains
    40    a given element value.
    41  * [`setproduct`](./setproduct.html) computes the _Cartesian product_ of multiple
    42    sets.
    43  * [`setsubtract`](./setsubtract.html) computes the _relative complement_ of two sets
    44  * [`setunion`](./setunion.html) computes the _union_ of
    45    multiple sets.