github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/docs/job-specification/hcl2/functions/collection/index-fn.mdx (about) 1 --- 2 layout: docs 3 page_title: index - Functions - Configuration Language 4 description: |- 5 The index function returns an element from the given list or map 6 using the given index or key. 7 --- 8 9 # `index` Function 10 11 `index` finds the element at the index when handling lists, or the element at 12 the key when handling maps. 13 14 ```hcl 15 index(list, value) 16 ``` 17 18 ## Examples 19 20 ```shell-session 21 > index(["a", "b", "c"], 1) 22 "b" 23 ``` 24 25 ```shell-session 26 > index({"a"=1, "c"=2, "d"=3}, "c") 27 2 28 ``` 29 30 ## Related Functions 31 32 - [`element`](/docs/job-specification/hcl2/functions/collection/element) retrieves a particular element from a list given 33 its index.