Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serverless: Uploaded file must be a non-empty zip.

I have a python serverless project that I use with AWS. But whenever I run sls deploy, i get this error and I noticed in my .serverless that it doesn't actually zip the file, only produces the .json files.

An error occurred: ParserLambdaFunction - Uploaded file must be a non-empty zip.

my yml looks like this:

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'

my package.json looks like this:

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

and my folder structure looks like this:

-my-service
--.serverless
--_pycache_
--_build
--node_modules
--standford-new-2017-06-09
--.gitignore
--handler.py
--package.json
--serverless.yml
--tsconfig.json
--typings.json
like image 775
noor Avatar asked Nov 07 '22 15:11

noor


1 Answers

On the one hand you can simply remove include or use

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

and as it says - put your code in a subfolder of your dir.

like image 158
nrhode Avatar answered Nov 14 '22 21:11

nrhode