github.com/muratcelep/terraform@v1.1.0-beta2-not-internal-4/website/docs/language/functions/tobool.html.md (about) 1 --- 2 layout: "language" 3 page_title: "tobool - Functions - Configuration Language" 4 sidebar_current: "docs-funcs-conversion-tobool" 5 description: |- 6 The tobool function converts a value to boolean. 7 --- 8 9 # `tobool` Function 10 11 `tobool` converts its argument to a boolean value. 12 13 Explicit type conversions are rarely necessary in Terraform because it will 14 convert types automatically where required. Use the explicit type conversion 15 functions only to normalize types returned in module outputs. 16 17 Only boolean values, `null`, and the exact strings `"true"` and `"false"` can be 18 converted to boolean. All other values will produce an error. 19 20 ## Examples 21 22 ``` 23 > tobool(true) 24 true 25 > tobool("true") 26 true 27 > tobool(null) 28 null 29 > tobool("no") 30 Error: Invalid function argument 31 32 Invalid value for "v" parameter: cannot convert "no" to bool: only the strings 33 "true" or "false" are allowed. 34 35 > tobool(1) 36 Error: Invalid function argument 37 38 Invalid value for "v" parameter: cannot convert number to bool. 39 ```