How to work with Lambda Layers

The benefits of using Lambda Layers when using a Lambda function are to keep your Lambda function library as clean and small as possible, and it opens up to keep sharing your code libraries and pip packages in the same versions in the cross of your project, and you can now bump a single Lambda function to a new layer version whit-out crashing all your old Lambda functions until you have tested the new layer version is working as you expect.

You can include up to five layers per function, so sometimes it makes sense to create bundle layers where you pack multi-packages into a single layer if you use it together many times and you need are bigger than five layers for a single Lambda function. In my sample here you will see I will create a pymongo layer and because I use MongoDB Atlas I need dnspython with it, here it makes sense to put both into the same layer.

Use GitHub actions to auto-deployment layers

One of the things I do to work easily with Lambda Layers is to use GitHub actions to automatic build when I bump a version or desire to use a new package for my project, and I can now reuse this layer in cross projects I want on inside my own AWS account if you have a organizations account I will recommend using a single account as “global account” where you keep your layers updated and share layers to your…

--

--

Paris Nakita Kejser
DevOps Engineer, Software Architect and Software Developering

DevOps Engineer, Software Architect, Software Developer, Data Scientist and identify me as a non-binary person.