pythonamazon-web-servicesaws-lambdadeploymentutilities

How to make all common functions centralised in AWS Lambda Function (Python)?


I have one use case where I have created ~40 Lambda Function (Python3.8). All these functions use 5 to 6 common custom functions or utilities that are available within the python code.

I wanted to know that is it possible to manage all these common static functions in a separate class and centralise it that will be used by all functions?

This will help me to make any changes in the common functions and auto replicate these changes to all functions rather than doing it in each function manually.

I know we can use custom class and import as a new Python file (along with lambda_handler) with deployment packages and import in code but this will again create overhead to make changes or replace each attached python file.

Please suggest the best way to manage it.

Please note, I am not using any CICD.


Solution

  • You can put your common code in a layer and then assign that layer to the Lambdas that use the common code. See Lambda Layers