github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/configuration/functions/tostring.html.md (about) 1 --- 2 layout: "functions" 3 page_title: "tostring - Functions - Configuration Language" 4 sidebar_current: "docs-funcs-conversion-tostring" 5 description: |- 6 The tostring function converts a value to a string. 7 --- 8 9 # `tostring` 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 `tostring` converts its argument to a string 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 Only the primitive types (string, number, and bool) can be converted to string. 22 All other values will produce an error. 23 24 ## Examples 25 26 ``` 27 > tostring("hello") 28 hello 29 > tostring(1) 30 1 31 > tostring(true) 32 true 33 > tostring([]) 34 Error: Invalid function argument 35 36 Invalid value for "v" parameter: cannot convert tuple to string. 37 ```