github.com/pulumi/terraform@v1.4.0/website/docs/language/functions/tonumber.mdx (about)

     1  ---
     2  page_title: tonumber - Functions - Configuration Language
     3  description: The tonumber function converts a value to a number.
     4  ---
     5  
     6  # `tonumber` Function
     7  
     8  `tonumber` converts its argument to a number 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 numbers, `null`, and strings containing decimal representations of numbers can be
    15  converted to number. All other values will produce an error.
    16  
    17  ## Examples
    18  
    19  ```
    20  > tonumber(1)
    21  1
    22  > tonumber("1")
    23  1
    24  > tonumber(null)
    25  null
    26  > tonumber("no")
    27  Error: Invalid function argument
    28  
    29  Invalid value for "v" parameter: cannot convert "no" to number: string must be
    30  a decimal representation of a number.
    31  ```