Skip to content

(core): stateful annotations #26778

@MrArnoldPalmer

Description

@MrArnoldPalmer

Describe the feature

I as a construct author, want to be able to change or remove annotations after they have been constructed.

Use Case

For example, the aws-lambda-nodejs.Function construct can use a runtime NODEJS_LATEST, which changes as new runtime versions are available. We currently warn users when they are using this runtime, and have dependencies listed in externalModules, since this indicates that they are relying on these packages being present somewhere other than their bundled handler. However, these dependencies may be present in a lambda layer.

Currently lambda layers are computed lazily which means we can't just check if the runtime is variable, external modules are passed, and there are no layers present within aws-lambda-nodejs.Function then add an annotation, as a user may call addLayers post construction and then the annotation would be inaccurate.

If we could remove an annotation, we could check for these conditions within a constructor, add the annotation, then override addLayers from the inheriting class to remove the annotation if present.

See #26763 for additional context

Proposed Solution

This was explored previously by @corymhall in this pr but it was dropped for the moment as solutions weren't ideal.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.92.0

Environment details (OS name and version, etc.)

MacOs

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/coreRelated to core CDK functionalityeffort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions