(Almost) universal AWS Lambda packager. It generates zip archive ready for uploading on AWS with no pain using just a simple config file.
Supports node and python out of the box, can be customised for other environments.
curl https://raw.githubusercontent.com/nogizhopaboroda/lapa/master/packer.py -o /usr/local/bin/lapa && chmod +x /usr/local/bin/lapanpm i -g https://github.com/nogizhopaboroda/lapanpm i --save-dev https://github.com/nogizhopaboroda/lapathen in package.json:
{
...
"scripts": {
"pack": "lapa"
}
...
}python <(curl https://raw.githubusercontent.com/nogizhopaboroda/lapa/master/packer.py) [arguments]A config file is either plain json file (packer.config.json) or js module (packer.config.js) that exports configuration object placed within project directory.
example packer.config.json:
{
"environment": "python",
"files": ["*.py", "*.ini"],
"ignore": ["lib/*", "bin/*"],
"dependencies": ["requests"],
"zipName": "./dist/my-lambda.zip"
}example packer.config.js:
//packer.config.js
//js configs are treated as regular js modules,
//so you can use variables, require another modules and so on
const common = {
"environment": "node",
"files": "*",
"ignore": ["node_modules/*"]
}
module.exports = [
{
...common,
"dependencyFile": "package.json",
"zipName": "./dist/my-lambda.zip"
},
{
...common,
"dependencyFile": "edge.package.json",
"zipName": "./dist/my-edge-lambda.zip"
},
]{ //can be an array (for multiple builds)
"environment": <String|Object>,
//optional fields
"files": <String|Array>,
"ignore": <String|Array>,
"dependencyFile": <String>,
"dependencies": <String|Array>,
"zipName": <String>,
"mapDirectories": <Object>
}environment:
environment to use when install dependencies. So far only node and python are supperted.
Can also be an object of dependencies installation instructions. In such case:
{
"environment": {
"installDependencies": "some-bundler install {dependencies}",
"installDependencyFile": [
"some-bundler install {dependencyFile}"
],
}
}where
{dependencies} - space-separated dependencies from config object
{dependencyFile} - dependency file from config object
files (Default: [*]):
file/directory masks to include to archive
ignore (Default: []):
file/directory masks to ignore
dependencyFile:
file to use as a dependency file
dependencies (Default: []):
list of dependencies
zipName (Default: lambda.zip):
output archive name
mapDirectories:
Change file directory in resulting archive. Example:
{
// src/a.js -> a.js
// b.js -> b.js
"mapDirectories": {
"src": "./"
}
}You can create config file in interactive mode
lapa --initApp will ask you several questions and try to guess you environment based on most common files type
within project directory simply run:
lapa- simple python project
- simple node project
- node project with 2 configs (lambda + edge)
- simple python project with requirements.txt
It's known issue if your pip is installed via brew. As a workaround just copy this setup.cfg file in your project on root level as in this example
python >= 2