github.com/jaredpalmer/terraform@v1.1.0-alpha20210908.0.20210911170307-88705c943a03/website/docs/language/functions/tostring.html.md (about)

     1  ---
     2  layout: "language"
     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  `tostring` converts its argument to a string 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 the primitive types (string, number, and bool) and `null` can be converted to string.
    18  All other values will produce an error.
    19  
    20  ## Examples
    21  
    22  ```
    23  > tostring("hello")
    24  hello
    25  > tostring(1)
    26  1
    27  > tostring(true)
    28  true
    29  > tostring(null)
    30  null
    31  > tostring([])
    32  Error: Invalid function argument
    33  
    34  Invalid value for "v" parameter: cannot convert tuple to string.
    35  ```