简体   繁体   English

如何使所有常用功能集中在 AWS Lambda Function (Python) 中?

[英]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 ).我有一个用例,我创建了 ~40 Lambda Function ( Python3.8 )。 All these functions use 5 to 6 common custom functions or utilities that are available within the python code.所有这些函数都使用 python 代码中可用的5 到 6 个常用自定义函数或实用程序

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?我想知道是否可以在单独的 class 中管理所有这些常见的 static 函数并将其集中起来以供所有函数使用?

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.这将帮助我对常用功能进行任何更改并将这些更改自动复制到所有功能,而不是手动在每个 function 中进行。

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.我知道我们可以使用自定义 class 并导入为新的 Python 文件(连同lambda_handler )与部署包并在代码中导入,但这将再次产生开销来进行更改或替换每个附加的 Z23EEEB4347BDD755DFC6B7EE9ZB 文件。

Please suggest the best way to manage it.请建议管理它的最佳方法。

Please note, I am not using any CICD.请注意,我没有使用任何 CICD。

You can put your common code in a layer and then assign that layer to the Lambdas that use the common code.您可以将公共代码放在一个层中,然后将该层分配给使用该公共代码的 Lambda。 See Lambda Layers参见Lambda 层

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM