AWS › Lambda & Serverless
How do Lambda layers help share common code and dependencies across multiple functions without duplicating that code in every deployment package?
IntermediateAnswer
A Lambda layer is a separate archive containing libraries, custom runtimes, or other dependencies that can be attached to multiple Lambda functions, meaning shared code, such as a common logging library or a large third party dependency, only needs to be packaged and updated in one place, keeping individual function deployment packages smaller and making it easier to maintain consistency across many related functions.
aws lambda publish-layer-version --layer-name common-utilities --zip-file fileb://layer.zipReal-world example A company with dozens of Lambda functions extracts their shared logging and error handling code into a single Lambda layer, attaching it to every function so that a bug fix in that shared logic only needs to be updated and republished once rather than in every individual function's deployment package.