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

     1  ---
     2  layout: "functions"
     3  page_title: "coalescelist - Functions - Configuration Language"
     4  sidebar_current: "docs-funcs-collection-coalescelist"
     5  description: |-
     6    The coalescelist function takes any number of list arguments and returns the
     7    first one that isn't empty.
     8  ---
     9  
    10  # `coalescelist` 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  `coalescelist` takes any number of list arguments and returns the first one
    17  that isn't empty.
    18  
    19  ## Examples
    20  
    21  ```
    22  > coalescelist(["a", "b"], ["c", "d"])
    23  [
    24    "a",
    25    "b",
    26  ]
    27  > coalescelist([], ["c", "d"])
    28  [
    29    "c",
    30    "d",
    31  ]
    32  ```
    33  
    34  To perform the `coalescelist` operation with a list of lists, use the `...`
    35  symbol to expand the outer list as arguments:
    36  
    37  ```
    38  > coalescelist([[], ["c", "d"]]...)
    39  [
    40    "c",
    41    "d",
    42  ]
    43  ```
    44  
    45  ## Related Functions
    46  
    47  * [`coalesce`](./coalesce.html) performs a similar operation with string
    48    arguments rather than list arguments.