aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.52k stars 3.86k forks source link

(aws_lambda): get the latest Lambda Layer version in the Lambda function construct. #29214

Open Koketjo001 opened 6 months ago

Koketjo001 commented 6 months ago

Describe the feature

Currently, the @aws-cdk/aws-lambda:recognizeLayerVersion feature flag only works if the lambda layer version and lambda function are in same stack.

https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda-readme.html#currentversion-updated-hashing-logic-for-layer-versions

Use Case

It would be great to have two different stacks, one for the lambda layer version and one for the lambda function. Changes to lambda layer version in the other stack should automatically trigger an update to the function referencing it that is in another stack.

SSM Parameter is used as a workaround for this use case but when the lambda layer version is updated, the lambda function does not automatically update, it has to be updated manually to reflect the changes in the lambda layer version. Without the SSM parameter, the error Export [name] cannot be updated as it is in use by stack since we cannot update the exports and imports which are in use by other stack is returned.

Proposed Solution

No response

Other Information

No response

Acknowledgements

CDK version used

2.118.0

Environment details (OS name and version, etc.)

MacOS, language=TypeScript

tim-finnigan commented 6 months ago

Thanks for the feature request. For more background here is the PR which introduced the changes in 2.27.0, which are referenced in the documentation that you linked.