github.com/eliastor/durgaform@v0.0.0-20220816172711-d0ab2d17673e/website/docs/language/functions/index_function.mdx (about) 1 --- 2 page_title: index - Functions - Configuration Language 3 description: The index function finds the element index for a given value in a list. 4 --- 5 6 # `index` Function 7 8 `index` finds the element index for a given value in a list. 9 10 ```hcl 11 index(list, value) 12 ``` 13 14 The returned index is zero-based. This function produces an error if the given 15 value is not present in the list. 16 17 ## Examples 18 19 ``` 20 > index(["a", "b", "c"], "b") 21 1 22 ``` 23 24 ## Related Functions 25 26 * [`element`](/language/functions/element) retrieves a particular element from a list given 27 its index.