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

     1  ---
     2  layout: "functions"
     3  page_title: "distinct - Functions - Configuration Language"
     4  sidebar_current: "docs-funcs-collection-distinct"
     5  description: |-
     6    The distinct function removes duplicate elements from a list.
     7  ---
     8  
     9  # `distinct` Function
    10  
    11  -> **Note:** This page is about Terraform 0.12 and later. For Terraform 0.11 and
    12  earlier, see
    13  [0.11 Configuration Language: Interpolation Syntax](../../configuration-0-11/interpolation.html).
    14  
    15  `distinct` takes a list and returns a new list with any duplicate elements
    16  removed.
    17  
    18  The first occurrence of each value is retained and the relative ordering of
    19  these elements is preserved.
    20  
    21  ## Examples
    22  
    23  ```
    24  > distinct(["a", "b", "a", "c", "d", "b"])
    25  [
    26    "a",
    27    "b",
    28    "c",
    29    "d",
    30  ]
    31  ```