github.com/muratcelep/terraform@v1.1.0-beta2-not-internal-4/website/docs/language/functions/slice.html.md (about) 1 --- 2 layout: "language" 3 page_title: "slice - Functions - Configuration Language" 4 sidebar_current: "docs-funcs-collection-slice" 5 description: |- 6 The slice function extracts some consecutive elements from within a list. 7 --- 8 9 # `slice` Function 10 11 `slice` extracts some consecutive elements from within a list. 12 13 ```hcl 14 slice(list, startindex, endindex) 15 ``` 16 17 `startindex` is inclusive, while `endindex` is exclusive. This function returns 18 an error if either index is outside the bounds of valid indices for the given 19 list. 20 21 ## Examples 22 23 ``` 24 > slice(["a", "b", "c", "d"], 1, 3) 25 [ 26 "b", 27 "c", 28 ] 29 ``` 30 31 ## Related Functions 32 33 * [`substr`](./substr.html) performs a similar function for characters in a 34 string, although it uses a length instead of an end index.