Package: drover
droverdrover: a command-line utility to deploy Python packages to AWS Lambda functionsBackgroundThis utility aims to provide a simple, repeatable, and efficient process for
deploying a Python package as a Lambda.To encourage separating infrequently changing Python dependencies in a separate
"requirements" layer, by defaultdroverrequires a list of regular expressions
to define which files to include in the Lambda function; all other files are
placed in a requirements layer that is then attached to the Lambda function.Next,drovergenerates and stores hashes for both the Lambda function and the
requirements layer. This allowsdroverto avoid redundantly updating the
Lambda function and/or requirements layer if no package contents have changed.As much as possible,droveravoids altering existing infrastructure.
Infrastructure utilities such asTerraformmay be used to create a
Lambda and manage its surrounding resources anddrovermay be used to update
the Lambda function as well as its layers.Supported PlatformsThis utility is continuously unit tested on a GNU/Linux system with Python 3.6,
3.7, and 3.8.UsageSettingsThe followingdrover.ymlsettings file demonstrates how to configure astagingstage that may be used to deploy a Python package to a Lambda namedbasic-lambdain theus-east-1region:stages:staging:region_name:us-east-1function_name:basic-lambdacompatible_runtime:python3.8function_file_patterns:-'^basic_lambda.*'function_extra_paths:-instanceupload_bucket:region_name:us-east-1bucket_name:drover-examplesThecompatible_runtimevalue will be used to define the compatible runtime for
both the requirements layer (if present) and the Lambda function.While processing files from the install path (see:--install-pathbelow), any
files matching regular expressions defined in thefunction_file_patternslist
will be included in the function; any remaining files will be included in the
requirements layer.Thefunction_extra_pathslist may contain additional paths to include in the
function layer archive; non-absolute paths will be relative to the current
working directory.Theupload_bucketmap may provide a S3 Bucket name and its associated region
for use when uploading Lambda function and layer archive files.Command line interfaceAssuming a Python package exists in thebasic_lambdadirectory, the following
commands demonstrate a simple Lambda deploy withdrover:pip install --target install basic_lambda
drover --install-path install stagingAssuming the Lambda is not already up to date,droverwill attempt to upload
the latest source and update the Lambda function:Requirements digest: None
Function digest: 0b37cf78f6ad4c137fb1f77751c0c0e759dd2d6c515937d33fae435b9e091f72
Skipping requirements upload
Uploading function archive...
Failed to upload function archive to bucket; falling back to direct file upload.
Updating function resource...
Updated function "basic-lambda" resource; size: 1.78 KiB; ARN: arn:aws:lambda:us-east-1:977874552542:function:basic-lambdaAdditional examplesFor more examples, see theexamplesdirectory.How to contributeContributions are welcome in the form of inquiries, issues, and pull requests.Development EnvironmentInitialize a development environment by executingnox -s dev-3.8; thedroverutility will be installed in the.nox/dev-3-8Python virtual environment
binary path.