github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/configuration/functions/index.html.md (about) 1 --- 2 layout: "functions" 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 -> **Note:** This page is about Terraform 0.12 and later. For Terraform 0.11 and 12 earlier, see 13 [0.11 Configuration Language: Interpolation Syntax](../../configuration-0-11/interpolation.html). 14 15 `index` finds the element index for a given value in a list. 16 17 ```hcl 18 index(list, value) 19 ``` 20 21 The returned index is zero-based. This function produces an error if the given 22 value is not present in the list. 23 24 ## Examples 25 26 ``` 27 > index(["a", "b", "c"], "b") 28 1 29 ``` 30 31 ## Related Functions 32 33 * [`element`](./element.html) retrieves a particular element from a list given 34 its index.