github.com/muratcelep/terraform@v1.1.0-beta2-not-internal-4/website/docs/language/functions/index_function.html.md (about)

     1  ---
     2  layout: "language"
     3  page_title: "index - Functions - Configuration Language"
     4  sidebar_current: "docs-funcs-collection-index"
     5  description: |-
     6    The index function finds the element index for a given value in a list.
     7  ---
     8  
     9  # `index` Function
    10  
    11  `index` finds the element index for a given value in a list.
    12  
    13  ```hcl
    14  index(list, value)
    15  ```
    16  
    17  The returned index is zero-based. This function produces an error if the given
    18  value is not present in the list.
    19  
    20  ## Examples
    21  
    22  ```
    23  > index(["a", "b", "c"], "b")
    24  1
    25  ```
    26  
    27  ## Related Functions
    28  
    29  * [`element`](./element.html) retrieves a particular element from a list given
    30    its index.