fix(lambda-layer-awscli): s3-deployment, stepfunctions-tasks, eks constructs create multiple identical AwsCliLayers (#32907) #33085
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #32907
Reason for this change
Multiple identical and possibly unused AwsCliLayers in a single stack are wasteful, and can cause deployments to fail if Lambda throttles layer creation requests.
Description of changes
AwsCliLayer.getOrCreate()
for getting or creating the singleton layer constructaws-s3-deployment
(the motivating caller)aws-eks
andaws-eks-v2-alpha
aws-stepfunctions-tasks
As a result of this change, the single AwsCliLayer is now created at the root of the stack, instead of each one being created near the construct that uses it. This requires changes to the test expectations which depend on the logical ID of the AwsCliLayer resource.
Describe any new or updated permissions being added
None
Description of how you validated changes
Added unit tests to cover new cases in
aws-s3-deployments
. Updated unit tests in other cdk modules.The snapshot tests also need to be updated. I've run
yarn integ
and verified that the changes are all expected, but I'm not sure what the proper way to update the snapshots in git is.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license