Serverless:上载的文件必须是非空的zip。

2024-10-01 09:32:21 发布

您现在位置:Python中文网/ 问答频道 /正文

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

An error occurred: ParserLambdaFunction - Uploaded file must be a non-empty 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'

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

^{pr2}$

我的文件夹结构如下:

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

Tags: buildawsjsonparserpackagemyymlservice
1条回答
网友
1楼 · 发布于 2024-10-01 09:32:21

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

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

就像上面说的-把你的代码放在你的dir的子文件夹里。在

相关问题 更多 >