本文介绍了Travis CI在广告代码中添加了“索引"部署到AWS Lambda期间在handler_name之前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Travis-ci部署lambda函数.我已经根据 Lambda创建了 .travis.yml 文件部署,请参见下面的文件内容.

I'm using Travis-ci to deploy lambda function. I've created .travis.yml file according to Lambda deployment, see file content below.

language: generic
deploy:
  provider: lambda
  function_name: MyFunction
  region: us-east-1
  role: correct_roleid
  runtime: python3.6
  handler_name: lambda/testfile.lambda_handler
  access_key_id: key_id
  secret_access_key:
    secure: secret

我的项目的文件夹结构:

The folder structure of my project:

|   .editorconfig
|   .gitignore
|   .travis.yml
\---lambda
        testfile.py

部署后,在 Handler 字段中,我具有 index.lambda/testfile.lambda_handler 值.

After the deployment, in Handler field I have index.lambda/testfile.lambda_handler value.

我的问题:

如何对Travis-ci说使用我在 .travis.yml 文件中设置的确切值?

How to say to Travis-ci use exact value, which I've set in .travis.yml file?

推荐答案

handler_name 必须是函数名称.您还应该设置 module_name (请参见 docs ).

handler_name needs to be the function name. You should also set module_name (see docs).

因此,请尝试以下操作:

So try something like:

module_name: lambda/testfile
handler_name: lambda_handler

如果这不起作用,请尝试在 lambda 文件夹中创建 __ init __.py .如果那不起作用,请尝试将 lambda_handler.py 移至根文件夹.您可以使其从文件夹中导入文件,以保持文件结构井井有条.

If that doesn't work, try creating __init__.py in lambda folder. And if that doesn't work, try moving lambda_handler.py to the root folder. You can make it import files from your folder to keep an organized file structure.

这篇关于Travis CI在广告代码中添加了“索引"部署到AWS Lambda期间在handler_name之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 16:36