Python 无服务器:上载的文件必须是非空zip文件。
我有一个用于AWS的python无服务器项目。但每当我运行sls deploy时,就会出现这个错误,我在.serverless中注意到它实际上并没有压缩文件,只生成.json文件 发生错误:ParserLambdaFunction-上载的文件必须是 非空拉链 我的yml看起来像这样:Python 无服务器:上载的文件必须是非空zip文件。,python,json,serverless,Python,Json,Serverless,我有一个用于AWS的python无服务器项目。但每当我运行sls deploy时,就会出现这个错误,我在.serverless中注意到它实际上并没有压缩文件,只生成.json文件 发生错误:ParserLambdaFunction-上载的文件必须是 非空拉链 我的yml看起来像这样: service: my-service provider: name: aws runtime: python3.6 package: individually: True plugins:
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'
{
"name": "my-service",
"description": "",
"version": "0.1.0",
"dependencies": {
"serverless-package-python-functions": "^0.2.3"
},
"devDependencies": {
"serverless-python-requirements": "^3.0.5"
}
}
my package.json如下所示:
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'
{
"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
一方面,您可以简单地删除
include
或使用
include:
- ./[put_your_function_code_in_a_folder]
artifact: ....
正如上面所说的,把你的代码放在目录的子文件夹中。你的
函数['parser']['package']['include']
是空的。我意识到这一点,但我不知道如何去修复它,尝试删除include
。