Hello,
I have a step-function running, but the size of each lambda is exactly the same and I am now getting the error Code storage limit exceeded when i try to deploy this.
For more complex functions (i.e. those with many dependencies) I usually have a subdirectory per function, and can then package it by directory.
If you are going to do it off a shared node_modules directory, I suggest you use the --legacy-bundling option. From the docs:
The --legacy-bundling argument will cause npm to install the package such that versions of npm prior to 1.4, such as the one included with node 0.8, can install the package. This eliminates all automatic deduping.
This means each module will have all of its dependencies contained in its own directory.
Another thing you can look at is moving your dev dependencies into a node_modules in the parent directory (the one above your service folder). They’ll still be available to Serverless but they won’t be packaged with your code. While it won’t help you with having the smallest possible package for each function it is a quick win to remove packages like the aws-sdk, compilers/transpilers, test frameworks, plugins (and their dependencies).
that is a good idea, to move dev dependencies, thanks and yes using --legacy-bundling does fix the issue. I am using the aws-sdk in my functions to access dynamoDB and S3 - is there an alternative way to package these?
The following libraries are available in the AWS Lambda execution environment, regardless of the supported runtime you use, so you don’t need to include them:
AWS SDK – AWS SDK for JavaScript version 2.22.0
AWS SDK for Python (Boto 3) version 1.4.4, Botocore version 1.5.13
Amazon Linux build of java-1.8.0-openjdk for Java.
If you can limit yourself the currently included version then there’s no need to include it in the upload package to use it.
START RequestId: 09714a20-26cd-11e7-9dc5-4f7f268fbac2 Version: $LATEST
Unable to import module 'execute_steps/index': Error
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/var/task/node_modules/jsonwebtoken/node_modules/joi/lib/date.js:7:14)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
END RequestId: 09714a20-26cd-11e7-9dc5-4f7f268fbac2
REPORT RequestId: 09714a20-26cd-11e7-9dc5-4f7f268fbac2 Duration: 57.48 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 25 MB