(aws_lambda): get the latest Lambda Layer version in the Lambda function construct.
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### 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
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### CDK version used
2.118.0
### Environment details (OS name and version, etc.)
MacOS, language=TypeScript
Contributor guide
Research direction
Start by reading the AWS Lambda construct documentation on current-version hashing and the @aws-cdk/aws-lambda:recognizeLayerVersion feature flag. Trace how a Lambda function references a layer version across stacks, including the SSM Parameter workaround and cross-stack export behavior. Done should include automatic function updates when a layer version changes in another stack, with tests covering that scenario.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100