Annotations

class aws_cdk.core.Annotations(*args, **kwargs)

Bases: object

Includes API for attaching annotations such as warning messages to constructs.

Methods

add_deprecation(api, message)

Adds a deprecation warning for a specific API.

Deprecations will be added only once per construct as a warning and will be deduplicated based on the api.

If the environment variable CDK_BLOCK_DEPRECATIONS is set, this method will throw an error instead with the deprecation message.

Parameters
  • api (str) – The API being deprecated in the format module.Class.property (e.g. @aws-cdk/core.Construct.node).

  • message (str) – The deprecation message to display, with information about alternatives.

Return type

None

add_error(message)

Adds an { “error”: } metadata entry to this construct.

The toolkit will fail synthesis when errors are reported.

Parameters

message (str) – The error message.

Return type

None

add_info(message)

Adds an info metadata entry to this construct.

The CLI will display the info message when apps are synthesized.

Parameters

message (str) – The info message.

Return type

None

add_warning(message)

Adds a warning metadata entry to this construct.

The CLI will display the warning when an app is synthesized, or fail if run in –strict mode.

Parameters

message (str) – The warning message.

Return type

None

Static Methods

classmethod of(scope)

Returns the annotations API for a construct scope.

Parameters

scope (IConstruct) – The scope.

Return type

Annotations