Token

class aws_cdk.core.Token(*args: Any, **kwargs)

Bases: object

Represents a special or lazily-evaluated value.

Can be used to delay evaluation of a certain value in case, for example, that it requires some context or late-bound data. Can also be used to mark values that need special processing at document rendering time.

Tokens can be embedded into strings while retaining their original semantics.

Static Methods

classmethod as_any(value)

Return a resolvable representation of the given value.

Parameters:

value (Any) –

Return type:

IResolvable

classmethod as_list(value, *, display_hint=None)

Return a reversible list representation of this token.

Parameters:
  • value (Any) –

  • display_hint (Optional[str]) – A hint for the Token’s purpose when stringifying it.

Return type:

List[str]

classmethod as_number(value)

Return a reversible number representation of this token.

Parameters:

value (Any) –

Return type:

Union[int, float]

classmethod as_string(value, *, display_hint=None)

Return a reversible string representation of this token.

If the Token is initialized with a literal, the stringified value of the literal is returned. Otherwise, a special quoted string representation of the Token is returned that can be embedded into other strings.

Strings with quoted Tokens in them can be restored back into complex values with the Tokens restored by calling resolve() on the string.

Parameters:
  • value (Any) –

  • display_hint (Optional[str]) – A hint for the Token’s purpose when stringifying it.

Return type:

str

classmethod compare_strings(possible_token1, possible_token2)

Compare two strings that might contain Tokens with each other.

Parameters:
  • possible_token1 (str) –

  • possible_token2 (str) –

Return type:

TokenComparison

classmethod is_unresolved(obj)

Returns true if obj represents an unresolved value.

One of these must be true:

  • obj is an IResolvable

  • obj is a string containing at least one encoded IResolvable

  • obj is either an encoded number or list

This does NOT recurse into lists or objects to see if they containing resolvables.

Parameters:

obj (Any) – The object to test.

Return type:

bool