I had defined several Lambdas with the Serverless Framework and deployed them, and the package size had grown to around 1.3GB, so I’ll reduce it.
Code
package:
excludeDevDependencies: false
patterns:
- "!.git/**"
- "!node_modules/**"
- "!aws/**"
- "!__pycache__/**"
- "!.venv/**"
Since it was a Python * Lambda setup, __pycache__/ and .venv/ were included.
Add entries to patterns to match your environment. A leading ! on a string means “exclude.”
With this, 1.3G -> 24mb 🥳
References
Serverless Framework - Packaging
How the Serverless Framework packages your AWS Lambda functions and other available options
