Reputation: 6141
I'm deploying an aws lambda function using serverless framework. My problem is there is a large file (44MB) that is deployed every time I do sls deploy -f any_fn
. I've had similar problems when there is a node_modules
folder (which can be quite big).
Is there a way to reduce the upload size by uploading the common files only once (and for all functions)? Because right now it keeps zipping and deploying that same binary file again and again though it never changes.
Upvotes: 1
Views: 3093
Reputation: 1
Use lambda containers and your problems will be solved! Lambda containers have a 10 GB image size limmit! You can add anything you want in there! I've made many express apps with Serverless http and lambda containers. You can also add an efs to your lambda and acess your files from there. Check this tutorial
Upvotes: 0
Reputation: 1
You can try using lambda layers. All you need to do is create separate serverless project for dependencies management for ex. node_modoles and rest of the services will refer to it (follow docs). This should reduce the deployment or package size of individual lambda significantly.
Upvotes: 0
Reputation: 2063
This was my solution:
exports.handler
so the code will be executed only one time (for
container). This allow you to deploy only the small files.
Upvotes: 1
Reputation: 200501
There's no way to do what you propose. AWS Lambda requires you to upload the entire package including all dependencies each time. Everything has to be inside the zip file that is deployed to Lambda.
Upvotes: 2