github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/website/content/docs/job-specification/hcl2/functions/collection/index-fn.mdx (about) 1 --- 2 layout: docs 3 page_title: index - Functions - Configuration Language 4 sidebar_title: index 5 description: The index function finds the element index for a given value in a list. 6 --- 7 8 # `index` Function 9 10 `index` finds the element index for a given value in a list. 11 12 ```hcl 13 index(list, value) 14 ``` 15 16 The returned index is zero-based. This function produces an error if the given 17 value is not present in the list. 18 19 ## Examples 20 21 ```shell-session 22 > index(["a", "b", "c"], "b") 23 1 24 ``` 25 26 ## Related Functions 27 28 - [`element`](/docs/job-specification/hcl2/functions/collection/element) retrieves a particular element from a list given 29 its index.