【问题标题】:Serverless: Uploaded file must be a non-empty zip.无服务器:上传的文件必须是非空 zip。
【发布时间】:2017-12-22 17:33:04
【问题描述】:

我有一个与 AWS 一起使用的 python 无服务器项目。但是每当我运行 sls deploy 时,我都会收到此错误,并且我在 .serverless 中注意到它实际上并没有压缩文件,只生成 .json 文件。

发生错误:ParserLambdaFunction - 上传的文件必须是 非空 zip。

我的 yml 看起来像这样:

service: my-service

provider:
  name: aws
  runtime: python3.6

package:
  individually: True

plugins:
  - serverless-package-python-functions
  - serverless-python-requirements

custom:
  pkgPyFuncs: # plugin configuration
    buildDir: _build

functions:
  parser:
    handler: handler.parser
    package:
      include:
      artifact: ${self:custom.pkgPyFuncs.buildDir}/my-service-dev-parser.zip
    events:
      - http:
          cors: true
          integration: LAMBDA
          passThrough: WHEN_NO_MATCH
          path: /
          method: post
          request: 
            parameters:
              querystring:
                application/json: "$input.path('$.body')"
                url: true
      - cloudwatchLog: '/aws/lambda/pythonParser'

我的 package.json 看起来像这样:

{
  "name": "my-service",
  "description": "",
  "version": "0.1.0",
  "dependencies": {
    "serverless-package-python-functions": "^0.2.3"
  },
  "devDependencies": {
    "serverless-python-requirements": "^3.0.5"
  }
}

我的文件夹结构如下:

-my-service
--.serverless
--_pycache_
--_build
--node_modules
--standford-new-2017-06-09
--.gitignore
--handler.py
--package.json
--serverless.yml
--tsconfig.json
--typings.json

【问题讨论】:

  • 您的functions['parser']['package']['include'] 为空。
  • 我知道,但我不知道如何解决它
  • 尝试删除include

标签: python json serverless


【解决方案1】:

一方面,您可以简单地删除 include 或使用

include:
   - ./[put_your_function_code_in_a_folder]
artifact: ....

正如它所说 - 将您的代码放在目录的子文件夹中。

【讨论】:

    猜你喜欢
    • 2022-01-18
    • 2021-05-01
    • 2021-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-07
    相关资源
    最近更新 更多