使用maven为aws lambda创建python部署包
我目前正在aws lambda上部署python包。使用virtualenv和zip工具,我可以轻松创建一个lambda zip文件,上传到aws并运行它。我使用以下博客创建包: 然而,我需要使用构建工具将我的代码与我公司的Jenkins集成。我们使用maven进行构建,我需要遵循同样的方法 我查看了如何按照博客中的步骤使用virtual env并创建zip文件。但是,我无法遵循maven教程中提到的步骤 有人遇到过同样的问题吗?如果是,你是如何解决的?如中所示,您是如何配置pom.xml来为python aws lambdas创建部署包的使用maven为aws lambda创建python部署包,python,maven,deployment,aws-lambda,aws-step-functions,Python,Maven,Deployment,Aws Lambda,Aws Step Functions,我目前正在aws lambda上部署python包。使用virtualenv和zip工具,我可以轻松创建一个lambda zip文件,上传到aws并运行它。我使用以下博客创建包: 然而,我需要使用构建工具将我的代码与我公司的Jenkins集成。我们使用maven进行构建,我需要遵循同样的方法 我查看了如何按照博客中的步骤使用virtual env并创建zip文件。但是,我无法遵循maven教程中提到的步骤 有人遇到过同样的问题吗?如果是,你是如何解决的?如中所示,您是如何配置pom.xml来为p
我们将非常感谢您的快速帮助。谢谢让我把这个问题分成两部分。首先,对于python lambda,您必须创建一个zip文件。为此,我建议使用 示例pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mygroup</groupId>
<artifactId>parent-pom</artifactId>
<version>0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>LambdaInstall</artifactId>
<name>Python Lambda Installation Package</name>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>install-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
通过将添加到my pom.xml中调用此python程序:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>python-build</id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>python</executable>
<arguments>
<argument>src/main/python/build/copyjwt.py</argument>
</arguments>
</configuration>
</plugin>
现在,为了将代码复制到我的zip文件中,我只需向上面显示的assembly.xml中再添加一个文件集:
<fileSet>
<directory>target/jwt</directory>
<outputDirectory>jwt</outputDirectory>
</fileSet>
让我把这个问题分成两部分。首先,对于python lambda,您必须创建一个zip文件。为此,我建议使用 示例pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mygroup</groupId>
<artifactId>parent-pom</artifactId>
<version>0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>LambdaInstall</artifactId>
<name>Python Lambda Installation Package</name>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>install-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
通过将添加到my pom.xml中调用此python程序:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>python-build</id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>python</executable>
<arguments>
<argument>src/main/python/build/copyjwt.py</argument>
</arguments>
</configuration>
</plugin>
现在,为了将代码复制到我的zip文件中,我只需向上面显示的assembly.xml中再添加一个文件集:
<fileSet>
<directory>target/jwt</directory>
<outputDirectory>jwt</outputDirectory>
</fileSet>
这正是我需要的。谢谢这个@mojokenThis听起来不错,但是如果所需的库还没有安装呢?也就是说,假设Jenkins节点拥有我们可能拥有的所有秘密库似乎是不合理的need@MartinThurn你说得对,在我写下这个答案后,我确实发现了这样的例子。最终,我在我的项目中创建了一个小型站点包目录,并将一些第三方库签入到源代码管理中,以便它们可以在我的Jenkins服务器上使用。这正是我所需要的。谢谢这个@mojokenThis听起来不错,但是如果所需的库还没有安装呢?也就是说,假设Jenkins节点拥有我们可能拥有的所有秘密库似乎是不合理的need@MartinThurn你说得对,在我写下这个答案后,我确实发现了这样的例子。最后,我在我的项目中创建了一个小型站点包目录,并将一些第三方库签入到源代码管理中,以便它们可以在我的Jenkins服务器上使用。