aws-cdk-lib.Token

class Token

LanguageType name
.NETAmazon.CDK.Token
Gogithub.com/aws/aws-cdk-go/awscdk/v2#Token
Javasoftware.amazon.awscdk.Token
Pythonaws_cdk.Token
TypeScript (source)aws-cdk-lib » Token

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.

Methods

NameDescription
static asAny(value)Return a resolvable representation of the given value.
static asList(value, options?)Return a reversible list representation of this token.
static asNumber(value)Return a reversible number representation of this token.
static asString(value, options?)Return a reversible string representation of this token.
static compareStrings(possibleToken1, possibleToken2)Compare two strings that might contain Tokens with each other.
static isUnresolved(obj)Returns true if obj represents an unresolved value.

static asAny(value)

public static asAny(value: any): IResolvable

Parameters

  • value any

Returns

  • IResolvable

Return a resolvable representation of the given value.


static asList(value, options?)

public static asList(value: any, options?: EncodingOptions): string[]

Parameters

  • value any
  • options EncodingOptions

Returns

  • string[]

Return a reversible list representation of this token.


static asNumber(value)

public static asNumber(value: any): number

Parameters

  • value any

Returns

  • number

Return a reversible number representation of this token.


static asString(value, options?)

public static asString(value: any, options?: EncodingOptions): string

Parameters

  • value any
  • options EncodingOptions

Returns

  • string

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.


static compareStrings(possibleToken1, possibleToken2)

public static compareStrings(possibleToken1: string, possibleToken2: string): TokenComparison

Parameters

  • possibleToken1 string
  • possibleToken2 string

Returns

  • TokenComparison

Compare two strings that might contain Tokens with each other.


static isUnresolved(obj)

public static isUnresolved(obj: any): boolean

Parameters

  • obj any — The object to test.

Returns

  • boolean

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 contain resolvables.