github.com/hugorut/terraform@v1.1.3/website/docs/language/functions/tobool.mdx (about)

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