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
AWS Lambda layers defined on the service level are not merged with layers defined per each function #11063
Comments
Hey @dimitor115 - thanks a lot for reporting and sorry you've run into trouble. I've verified and managed to replicate this behavior - I agree that it's quite surprising and might be potentially a bug, however, we need to be careful with the potential change here, as it would be a breaking change for people that might depend on current behavior. I will bring up the. issue internally and report back. |
Given this is a breaking change I don't see how we can change that in v3. For comparison, do |
Hey @dimitor115 - just for clarification - this is not preventing specific settings but creates inconvenience, where in some cases you need to repeat certain layers for each function instead of specifying it once at the provider level? After thinking about it more, I think there are reasons for both override and extend behavior when having layers defined on the provider and on function level. |
@pgrzesik Hey, you are right the current behaviour does not prevent me from configuring the layers as needed, however, it is super painful in my case, because I would need to add it manually to around 150 handlers. Of course, I understand that it would be a breaking change and because of that, you won't change it soon (if even), however, I think the current behaviour should be explicitly described in the documentation :) |
I totally agree with that @dimitor115. If anyone would be interested in submitting a PR with clarification in docs, we'd be more than happy to accept it 🙌 |
I've updated the docs, feel free to take a look :) Regarding to the issue, perhaps we could make overriding to be the default behaviour and add an option (perhaps a config in provider:
...
mergeLayers: true # Maybe on global level, for example However, merging them might exceed the 5 layers limit. E.g, 3 layers on the service level, and 3 layers in the function level. Not sure if this is is an issue or not though, Cloudformation might just block the update if it detects more than 5 layers. |
Are you certain it's a bug?
Is the issue caused by a plugin?
Are you using the latest version?
Is there an existing issue for this?
Issue description
According to the serverless framework documentation, there is an option to define the Lambda Layer on the service level as well as on the single function level: docs. I'm expecting the list of layers defined "globally" should be merged with the list of layers defined on each function layer.
After running the
serverless package
command with the service configuration defined below, the Cloud Formation template in the HelloLambdaFunction resource definition contains only the layer defined on the function layer, while it should have both.This overriding behaviour is very annoying, especially when using plugins like serverless-plugin-lambda-insights. This one is adding a LambdaInsights layer to each handler, so I'm unable to define a global layer for all my handlers in the service.
Service configuration (serverless.yml) content
Command name and used flags
serverless package
Command output
Packaging layers-bug-reproduction for stage dev (us-east-1) ✔ Service packaged (0s)
Environment information
The text was updated successfully, but these errors were encountered: