aws-cdk-lib.Tokenization

class Tokenization

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

Less oft-needed functions to manipulate Tokens.

Methods

NameDescription
static isResolvable(obj)Return whether the given object is an IResolvable object.
static resolve(obj, options)Resolves an object by evaluating all tokens and removing any undefined or empty objects or arrays.
static reverse(x, options?)Reverse any value into a Resolvable, if possible.
static reverseCompleteString(s)Un-encode a string which is either a complete encoded token, or doesn't contain tokens at all.
static reverseList(l)Un-encode a Tokenized value from a list.
static reverseNumber(n)Un-encode a Tokenized value from a number.
static reverseString(s)Un-encode a string potentially containing encoded tokens.
static stringifyNumber(x)Stringify a number directly or lazily if it's a Token.

static isResolvable(obj)

public static isResolvable(obj: any): boolean

Parameters

  • obj any

Returns

  • boolean

Return whether the given object is an IResolvable object.

This is different from Token.isUnresolved() which will also check for encoded Tokens, whereas this method will only do a type check on the given object.


static resolve(obj, options)

public static resolve(obj: any, options: ResolveOptions): any

Parameters

  • obj any — The object to resolve.
  • options ResolveOptions — Prefix key path components for diagnostics.

Returns

  • any

Resolves an object by evaluating all tokens and removing any undefined or empty objects or arrays.

Values can only be primitives, arrays or tokens. Other objects (i.e. with methods) will be rejected.


static reverse(x, options?)

public static reverse(x: any, options?: ReverseOptions): IResolvable

Parameters

  • x any
  • options ReverseOptions

Returns

  • IResolvable

Reverse any value into a Resolvable, if possible.

In case of a string, the string must not be a concatenation.


static reverseCompleteString(s)

public static reverseCompleteString(s: string): IResolvable

Parameters

  • s string

Returns

  • IResolvable

Un-encode a string which is either a complete encoded token, or doesn't contain tokens at all.

It's illegal for the string to be a concatenation of an encoded token and something else.


static reverseList(l)

public static reverseList(l: string[]): IResolvable

Parameters

  • l string[]

Returns

  • IResolvable

Un-encode a Tokenized value from a list.


static reverseNumber(n)

public static reverseNumber(n: number): IResolvable

Parameters

  • n number

Returns

  • IResolvable

Un-encode a Tokenized value from a number.


static reverseString(s)

public static reverseString(s: string): TokenizedStringFragments

Parameters

  • s string

Returns

  • TokenizedStringFragments

Un-encode a string potentially containing encoded tokens.


static stringifyNumber(x)

public static stringifyNumber(x: number): string

Parameters

  • x number

Returns

  • string

Stringify a number directly or lazily if it's a Token.

If it is an object (i.e., { Ref: 'SomeLogicalId' }), return it as-is.