Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BucketDeployment creates multiple identical, unused AwsCliLayers #32907

Open
wimlewis-amazon opened this issue Jan 14, 2025 · 0 comments
Open

Comments

@wimlewis-amazon
Copy link

If a stack contains several BucketDeployment constructs, even though the construct will only create one underlying custom resource provider and lambda, it will create a separate AwsCliLayer for each construct. All but one of these lambda layers will be unused.

You can see the bug in the constructor for BucketDeployment in bucket-deployment.ts. It invokes new BucketDeploymentSingletonFunction(...), which I assume is in charge of not creating multiple identical resource provider lambdas. However, one of the values passed to that function is layers: [new AwsCliLayer(this, 'AwsCliLayer')] (link to code). This value is evaluated before the singleton function logic is called, which means that a new AwsCliLayer is created unconditionally. Only the first one will actually be referenced by any lambda! This can be confirmed by examining the synthesized template or by looking at the lambda layers in the AWS console.

In addition to being wasteful, this is also causing deployment failures for us, because CFN attempts to create/update all of those layers simultaneously, resulting in a throttling error ("Resource handler returned message: "Rate exceeded (Service: AWSLambdaInternal; Status Code: 400; Error Code: ThrottlingException ..."). This may be the cause of issue #26940, possibly, although their description sounds a little bit different from ours.

What I think should happen instead: Only one AwsCliLayer needs to exist per stack. This can be referenced by multiple BucketDeplyments' lambda handlers. Note that even though BucketDeployment may create multiple "singletons" for different configurations (EFS, ephemeral-storage size, etc etc), they can all share the same AwsCliLayer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant