aws-cdk-lib.Lazy

class Lazy

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

Lazily produce a value.

Can be used to return a string, list or numeric value whose actual value will only be calculated later, during synthesis.

Methods

NameDescription
static any(producer, options?)Defer the one-time calculation of an arbitrarily typed value to synthesis time.
static list(producer, options?)Defer the one-time calculation of a list value to synthesis time.
static number(producer)Defer the one-time calculation of a number value to synthesis time.
static string(producer, options?)Defer the one-time calculation of a string value to synthesis time.
static uncachedAny(producer, options?)Defer the calculation of an untyped value to synthesis time.
static uncachedList(producer, options?)Defer the calculation of a list value to synthesis time.
static uncachedNumber(producer)Defer the calculation of a number value to synthesis time.
static uncachedString(producer, options?)Defer the calculation of a string value to synthesis time.

static any(producer, options?)

public static any(producer: IStableAnyProducer, options?: LazyAnyValueOptions): IResolvable

Parameters

  • producer IStableAnyProducer
  • options LazyAnyValueOptions

Returns

  • IResolvable

Defer the one-time calculation of an arbitrarily typed value to synthesis time.

Use this if you want to render an object to a template whose actual value depends on some state mutation that may happen after the construct has been created.

The inner function will only be invoked one time and cannot depend on resolution context.


static list(producer, options?)

public static list(producer: IStableListProducer, options?: LazyListValueOptions): string[]

Parameters

  • producer IStableListProducer
  • options LazyListValueOptions

Returns

  • string[]

Defer the one-time calculation of a list value to synthesis time.

Use this if you want to render a list to a template whose actual value depends on some state mutation that may happen after the construct has been created.

If you are simply looking to force a value to a string[] type and don't need the calculation to be deferred, use Token.asList() instead.

The inner function will only be invoked once, and the resolved value cannot depend on the Stack the Token is used in.


static number(producer)

public static number(producer: IStableNumberProducer): number

Parameters

  • producer IStableNumberProducer

Returns

  • number

Defer the one-time calculation of a number value to synthesis time.

Use this if you want to render a number to a template whose actual value depends on some state mutation that may happen after the construct has been created.

If you are simply looking to force a value to a number type and don't need the calculation to be deferred, use Token.asNumber() instead.

The inner function will only be invoked once, and the resolved value cannot depend on the Stack the Token is used in.


static string(producer, options?)

public static string(producer: IStableStringProducer, options?: LazyStringValueOptions): string

Parameters

  • producer IStableStringProducer
  • options LazyStringValueOptions

Returns

  • string

Defer the one-time calculation of a string value to synthesis time.

Use this if you want to render a string to a template whose actual value depends on some state mutation that may happen after the construct has been created.

If you are simply looking to force a value to a string type and don't need the calculation to be deferred, use Token.asString() instead.

The inner function will only be invoked once, and the resolved value cannot depend on the Stack the Token is used in.


static uncachedAny(producer, options?)

public static uncachedAny(producer: IAnyProducer, options?: LazyAnyValueOptions): IResolvable

Parameters

  • producer IAnyProducer
  • options LazyAnyValueOptions

Returns

  • IResolvable

Defer the calculation of an untyped value to synthesis time.

Use of this function is not recommended; unless you know you need it for sure, you probably don't. Use Lazy.any() instead.

The inner function may be invoked multiple times during synthesis. You should only use this method if the returned value depends on variables that may change during the Aspect application phase of synthesis, or if the value depends on the Stack the value is being used in. Both of these cases are rare, and only ever occur for AWS Construct Library authors.


static uncachedList(producer, options?)

public static uncachedList(producer: IListProducer, options?: LazyListValueOptions): string[]

Parameters

  • producer IListProducer
  • options LazyListValueOptions

Returns

  • string[]

Defer the calculation of a list value to synthesis time.

Use of this function is not recommended; unless you know you need it for sure, you probably don't. Use Lazy.list() instead.

The inner function may be invoked multiple times during synthesis. You should only use this method if the returned value depends on variables that may change during the Aspect application phase of synthesis, or if the value depends on the Stack the value is being used in. Both of these cases are rare, and only ever occur for AWS Construct Library authors.


static uncachedNumber(producer)

public static uncachedNumber(producer: INumberProducer): number

Parameters

  • producer INumberProducer

Returns

  • number

Defer the calculation of a number value to synthesis time.

Use of this function is not recommended; unless you know you need it for sure, you probably don't. Use Lazy.number() instead.

The inner function may be invoked multiple times during synthesis. You should only use this method if the returned value depends on variables that may change during the Aspect application phase of synthesis, or if the value depends on the Stack the value is being used in. Both of these cases are rare, and only ever occur for AWS Construct Library authors.


static uncachedString(producer, options?)

public static uncachedString(producer: IStringProducer, options?: LazyStringValueOptions): string

Parameters

  • producer IStringProducer
  • options LazyStringValueOptions

Returns

  • string

Defer the calculation of a string value to synthesis time.

Use of this function is not recommended; unless you know you need it for sure, you probably don't. Use Lazy.string() instead.

The inner function may be invoked multiple times during synthesis. You should only use this method if the returned value depends on variables that may change during the Aspect application phase of synthesis, or if the value depends on the Stack the value is being used in. Both of these cases are rare, and only ever occur for AWS Construct Library authors.