AWS Lambda和Java的Travis-CI部署问题

时间:2019-07-05 23:54:54

标签: travis-ci

在将代码部署到Java项目的lambda时,最初出现了一个问题,index.被添加到我的处理程序路径中。使用:https://stackoverflow.com/a/49620548/2612651我能够解决这个问题。

现在问题出在Java中,它正在使用module_name.handler_name,而不是.,应该是::

旁注在任何地方都有所有.travis.yml命令的简明清单吗?我似乎找不到它。

这是我的.travis.yml文件的deploy部分,它将两个工件放到我希望的位置。

deploy:
  - provider: lambda
    access_key_id: $AWS_KEY
    secret_access_key: $AWS_SECRET
    function_name: "grant-jwt"
    region: "us-east-2"
    role: "<arn>"
    runtime: "java8"
    module_name: "com.dapper.cloud.function.GrantJwt"
    handler_name: "handleRequest"
    file: "./grant-jwt/target/grant-jwt-0.0.1-SNAPSHOT.jar"

- provider: lambda
    access_key_id: $AWS_KEY
    secret_access_key: $AWS_SECRET
    function_name: "verify-jwt"
    region: "us-east-2"
    role: "<arn>"
    runtime: "java8"
    module_name: "com.dapper.cloud.function.VerifyJwt"
    handler_name: "handleRequest"
    file: "./verify-jwt/target/verify-jwt-0.0.1-SNAPSHOT.jar"

1 个答案:

答案 0 :(得分:0)

所以我实际上也遇到了这个问题,当我找到答案时,我感到很傻。正确的方法是使用module_name作为包路径,而handler_name的名称为Class::handlerFunc。另外,不支持file,请查看documentation所需的参数为zip

因此您的情况应该是

deploy:
  - provider: lambda
    access_key_id: $AWS_KEY
    secret_access_key: $AWS_SECRET
    function_name: "grant-jwt"
    region: "us-east-2"
    role: "<arn>"
    runtime: "java8"
    module_name: "com.dapper.cloud.function"
    handler_name: "GrantJwt::handleRequest"
    zip: "./grant-jwt/target/grant-jwt-0.0.1-SNAPSHOT.jar"

- provider: lambda
    access_key_id: $AWS_KEY
    secret_access_key: $AWS_SECRET
    function_name: "verify-jwt"
    region: "us-east-2"
    role: "<arn>"
    runtime: "java8"
    module_name: "com.dapper.cloud.function"
    handler_name: "VerifyJwt::handleRequest"
    zip: "./verify-jwt/target/verify-jwt-0.0.1-SNAPSHOT.jar"