Previously, you would have to package and deploy this shared code together with all the functions using it. Now, you can put common components in a ZIP file and upload it as a Lambda Layer. Your function code doesn鈥檛 need to be changed and can reference the libraries in the layer as it would normally do.
Layers can be used within an AWS account, shared between accounts, or shared publicly with the broad developer community.
I was thinking about this the other day. Having a layer with all the middleware pre-installed would speed up deployments a tiny bit (middy isn't that large, especially when using the mono-repos in v1). It would make more sense to configure your middlewares as a layer then share it to all of the lambdas that would use it. Did you have a specific use case in mind for this?
The main thought was to get the small performance boost.
In the setup I've been using the lambda code is bundled with middy and other dependencies.
A secondary outcome would be being able to unbundle middy core/middlewares.
Check out the v1 alpha branch, they're unbundled there. It's really stable for an alpha. Will likely be stable early next year.
beta will be out shortly: https://github.com/middyjs/middy/pull/457
[close]
Most helpful comment
Check out the v1 alpha branch, they're unbundled there. It's really stable for an alpha. Will likely be stable early next year.