I’m trying to deploy a new Python 3.6 project to AWS Lambda but I"m unable to do so because of the following error:
Serverless: Zipping required Python packages...
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Error --------------------------------------------------
ENOMEM: not enough memory, open '/c/ws/my-project/node_modules/lodash/stubObject.js'
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Stack Trace --------------------------------------------
Error: ENOMEM: not enough memory, open '/c/ws/my-project/node_modules/lodash/stubObject.js'
at Package.getFileContent (/usr/lib/node_modules/serverless/lib/plugins/package/lib/zipService.js:116:15)
at Package.getFileContentAndStat (/usr/lib/node_modules/serverless/lib/plugins/package/lib/zipService.js:105:12)
at Array.map (<anonymous>)
at WriteStream.output.on (/usr/lib/node_modules/serverless/lib/plugins/package/lib/zipService.js:83:29)
at emitOne (events.js:116:13)
at WriteStream.emit (events.js:211:7)
at /usr/lib/node_modules/serverless/node_modules/graceful-fs/graceful-fs.js:214:14
at /usr/lib/node_modules/serverless/node_modules/graceful-fs/graceful-fs.js:241:16
at FSReqWrap.oncomplete (fs.js:135:15)
I understand there’s a limit to the size of Lambda packages (250MB) and my project directory is pretty fat clocking in at about 270MB. However, I get this error even when just trying to package the project.
I’m using the serverless-python-requirements plugin and I’m dockerizing my project as well.
For completion’s sake this is my serverless.yml:
service: my-project
provider:
name: aws
runtime: python3.6
region: us-west-2
functions:
main:
handler: handler.main
events:
- http:
path: /
method: post
plugins:
- serverless-python-requirements
custom:
pythonRequirements:
dockerizePip: non-linux
zip: true
Anyone have any idea what might happening?
UPDATE:
Deleting arbitrary files to decrease the size of the project allowed me to successfully run the package command (creating a useless, non-functional package). Looking up the project size limit I found out it’s actually 50MB which is far too small for what I need so there’s probably some failsafe in the base AWS Lambda docker image that’s being used to build the package that prevents it from making packages that are too large.