我目前正在awslambda上部署python包。使用virtualenv和zip工具,我可以创建一个lambda zip文件,以便上传到aws并运行它。我使用以下博客创建包:https://joarleymoraes.com/hassle-free-python-lambda-deployment/。在
但是,我需要使用一个构建工具来将我的代码与我公司的Jenkins集成。我们使用maven构建,我也需要遵循同样的方法。在
我查看了maven-exec-plugin,以了解如何按照博客中的步骤使用virtual env并创建zip文件。但是,我无法遵循maven教程中提到的步骤。在
有人遇到过同样的问题吗?如果是,你是怎么解决的?在中,您如何配置pom.xml文件为pythonawslambdas创建部署包?在
我们将非常感谢您的快速帮助。谢谢
让我把这个问题分成两部分。首先,对于python lambda,必须创建一个zip文件。为此,我建议使用Maven Assembly Plugin。在
样品pom.xml文件公司名称:
样品程序集.xml公司名称:
^{pr2}$如果lambda只使用标准python库,那么这就是您所需要的全部。当您需要bot3或其他一些AWS没有在lambda节点上预先安装的库时,复杂性就会出现。为此,您必须将库添加到zip文件中。在
我希望有一种方法可以在任何开发人员的PC上,甚至在Jenkins节点上都能工作,所以我编写了一个小python应用程序,它可以找到库的位置(在site packages目录下)并将其复制到应用程序目标目录中。在这个例子中,我需要jwt:
这个python程序是通过将Maven Exec Plugin添加到my中来调用的pom.xml文件公司名称:
现在为了将代码复制到我的zip文件中,我只需要再添加一个文件集到程序集.xml我在上面展示了:
相关问题 更多 >
编程相关推荐