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
orfalse
- 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, wherekey
andvalue
are the string representations of each of the mapping’s key-value pairs
Declaration
fn::toString: value-to-encode
Parameters
Property | Type | Description |
---|---|---|
value-to-encode | any | The value to encode as a string. |
Returns
The decoded value.
Example
Definition
values:
string-value
fn::toString:
hello: world
from: [ "pulumi", "esc" ]
Evaluated result
{
"string-value": "hello=world,from=pulumi,esc"
}
Thank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.