github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/configuration/functions/tolist.html.md (about) 1 --- 2 layout: "functions" 3 page_title: "tolist - Functions - Configuration Language" 4 sidebar_current: "docs-funcs-conversion-tolist" 5 description: |- 6 The tolist function converts a value to a list. 7 --- 8 9 # `tolist` 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 `tolist` converts its argument to a list value. 16 17 Explicit type conversions are rarely necessary in Terraform because it will 18 convert types automatically where required. Use the explicit type conversion 19 functions only to normalize types returned in module outputs. 20 21 Pass a _set_ value to `tolist` to convert it to a list. Since set elements are 22 not ordered, the resulting list will have an undefined order that will be 23 consistent within a particular run of Terraform. 24 25 ## Examples 26 27 ``` 28 > tolist(["a", "b", "c"]) 29 [ 30 "a", 31 "b", 32 "c", 33 ] 34 ``` 35 36 Since Terraform's concept of a list requires all of the elements to be of the 37 same type, mixed-typed elements will be converted to the most general type: 38 39 ``` 40 > tolist(["a", "b", 3]) 41 [ 42 "a", 43 "b", 44 "3", 45 ] 46 ```