Lazy

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

Bases: object

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.

Static Methods

classmethod any(producer, *, display_hint=None, omit_empty_array=None)

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.

Parameters:
  • producer (IStableAnyProducer) –

  • display_hint (Optional[str]) – Use the given name as a display hint. Default: - No hint

  • omit_empty_array (Optional[bool]) – If the produced value is an array and it is empty, return ‘undefined’ instead. Default: false

Return type:

IResolvable

classmethod any_value(producer, *, display_hint=None, omit_empty_array=None)

(deprecated) 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.

Parameters:
  • producer (IAnyProducer) –

  • display_hint (Optional[str]) – Use the given name as a display hint. Default: - No hint

  • omit_empty_array (Optional[bool]) – If the produced value is an array and it is empty, return ‘undefined’ instead. Default: false

Deprecated:

Use Lazy.any() or Lazy.uncachedAny() instead.

Stability:

deprecated

Return type:

IResolvable

classmethod list(producer, *, display_hint=None, omit_empty=None)

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.

Parameters:
  • producer (IStableListProducer) –

  • display_hint (Optional[str]) – Use the given name as a display hint. Default: - No hint

  • omit_empty (Optional[bool]) – If the produced list is empty, return ‘undefined’ instead. Default: false

Return type:

List[str]

classmethod list_value(producer, *, display_hint=None, omit_empty=None)

(deprecated) 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.

Parameters:
  • producer (IListProducer) –

  • display_hint (Optional[str]) – Use the given name as a display hint. Default: - No hint

  • omit_empty (Optional[bool]) – If the produced list is empty, return ‘undefined’ instead. Default: false

Deprecated:

Use Lazy.list() or Lazy.uncachedList() instead.

Stability:

deprecated

Return type:

List[str]

classmethod number(producer)

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.

Parameters:

producer (IStableNumberProducer) –

Return type:

Union[int, float]

classmethod number_value(producer)

(deprecated) 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.

Parameters:

producer (INumberProducer) –

Deprecated:

Use Lazy.number() or Lazy.uncachedNumber() instead.

Stability:

deprecated

Return type:

Union[int, float]

classmethod string(producer, *, display_hint=None)

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.

Parameters:
  • producer (IStableStringProducer) –

  • display_hint (Optional[str]) – Use the given name as a display hint. Default: - No hint

Return type:

str

classmethod string_value(producer, *, display_hint=None)

(deprecated) Defer the 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.

Parameters:
  • producer (IStringProducer) –

  • display_hint (Optional[str]) – Use the given name as a display hint. Default: - No hint

Deprecated:

Use Lazy.string() or Lazy.uncachedString() instead.

Stability:

deprecated

Return type:

str

classmethod uncached_any(producer, *, display_hint=None, omit_empty_array=None)

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.

Parameters:
  • producer (IAnyProducer) –

  • display_hint (Optional[str]) – Use the given name as a display hint. Default: - No hint

  • omit_empty_array (Optional[bool]) – If the produced value is an array and it is empty, return ‘undefined’ instead. Default: false

Return type:

IResolvable

classmethod uncached_list(producer, *, display_hint=None, omit_empty=None)

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.

Parameters:
  • producer (IListProducer) –

  • display_hint (Optional[str]) – Use the given name as a display hint. Default: - No hint

  • omit_empty (Optional[bool]) – If the produced list is empty, return ‘undefined’ instead. Default: false

Return type:

List[str]

classmethod uncached_number(producer)

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.

Parameters:

producer (INumberProducer) –

Return type:

Union[int, float]

classmethod uncached_string(producer, *, display_hint=None)

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.

Parameters:
  • producer (IStringProducer) –

  • display_hint (Optional[str]) – Use the given name as a display hint. Default: - No hint

Return type:

str