(core): stateful annotations #26778
Labels
@aws-cdk/core
Related to core CDK functionality
effort/medium
Medium work item – several days of effort
feature-request
A feature should be added or improved.
p2
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 runtimeNODEJS_LATEST
, which changes as new runtime versions are available. We currently warn users when they are using this runtime, and have dependencies listed inexternalModules
, 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 calladdLayers
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
CDK version used
2.92.0
Environment details (OS name and version, etc.)
MacOs
The text was updated successfully, but these errors were encountered: