Bundle up Python deployment packages for AWS Lambda, including source code, configs, and dependencies with extension modules.
With pipsi:
$ pipsi install make-lambda-package
Or pip:
$ pip install make-lambda-package
Packaging dependencies with the --requirements-file
option requires
the docker
command to be in your $PATH
.
Dependencies will be built in a lambci/lambda:build-python2.7
container by default.
To use it:
$ make-lambda-package --help
Usage: make-lambda-package [OPTIONS] <path_or_url>
Bundle up a deployment package for AWS Lambda.
From your local filesystem:
$ make-lambda-package .
...
dist/lambda-package.zip
Or from a remote git repository:
$ make-lambda-package https://github.com/NoRedInk/make-lambda-package.git
...
vendor/dist/NoRedInk-make-lambda-package.zip
Use # fragment to specify a commit or a branch:
$ make-lambda-package https://github.com/NoRedInk/make-lambda-package.git#v1.0.0
Dependencies specified with --requirements-file will built using a docker
container that replicates AWS Lambda's execution environment, so that
extension modules are correctly packaged.
When packaging a local source, --work-dir defaults to `.`:
* ./build will hold a virtualenv for building dependencies if specified.
* ./dist is where the zipped package will be saved
When packaging a remote source, --work-dir defaults to `./vendor`.
Options:
--repo-source-files <glob_pattern_in_source>
Source files to package.
--requirements-file <path_in_source>
Dependencies to package.
--local-source-file <path_from_cwd> <path_in_zip>
Files in the current working directory to
package. Useful for config files.
--work-dir <output_directory> Where to store intermediary files and the
zipped package.
--runtime <lambda_runtime> Lambda runtime. Docker image
`lambci/lambda:build-{runtime}` will be used
for the build.
--help Show this message and exit.
Install packages and run tests:
$ pipenv install
$ pipenv install -d
$ pipenv shell
$ pytest