1. Docs
  2. Pulumi ESC
  3. Environment Definition Reference
  4. Built-in Functions
  5. fn::toString

fn::toString

The fn::toString built-in function encodes a value as its string representation. This can be used to encode values for use in positions that only accept strings. If any input to fn::toString is a secret, the encoded values is also a secret.

  • Boolean values are encoded as true or false
  • Number values are encoded as the decimal representation of their whole and fractional parts
  • Strings are encoded verbatim
  • Binary data is encoded as its Base64-encoded representation
  • List values are encoded as a comma-separated list of the string representations of their entries
  • Mapping values are encoded as a comma-separated list of key=value pairs, where key and value are the string representations of each of the mapping’s key-value pairs

Declaration

fn::toString: value-to-encode
Copy

Parameters

PropertyTypeDescription
value-to-encodeanyThe value to encode as a string.

Returns

The decoded value.

Example

Definition

values:
  string-value
    fn::toString:
      hello: world
      from: [ "pulumi", "esc" ]
Copy

Evaluated result

{
  "string-value": "hello=world,from=pulumi,esc"
}
Copy

Was this page helpful?