Package: lambda-setuptools
lambda-setuptoolsA Command extension to setuptools that builds an AWS Lambda compatible zip file and uploads it to an S3 bucketSimply addsetup_requires=['lambda_setuptools']as an attribute to yoursetup.pyfileThis extension adds two new commands to setuptools:ldistUsage:ldist --exclude-lambda-packages=<True | true | Yes | yes | False | false | No | no> --include-version=<True | true | Yes | yes | False | false | No | no> --build-layer=<True | true | Yes | yes | False | false | No | no> --layer-dir=<my_layer_dir>Effect: This will build (usingbdist_wheel) and install your package, along with all of the dependencies ininstall_requiresexclude-lambda-packagesis optional. If not present it will default toTrue. IfTrue, all packages provided by the
AWS Lambda execution environment will be excluded from your lambda function packageinclude-versionis optional. If not present it will default toTruebuild-layeris optional. If not present it will default toFalse. Set toTrueto build a layer instead of a functionlayer-diris optional. Defaults topython. Only used ifbuild-layerisTrueIt ishighlyrecommended that youDO NOTincludeboto3orbotocorein yourinstall_requiresdependencies as these are provided by the AWS Lambda environment. Include them at your own peril!The result will be indist/[your-package-name]-[version].zip(along with your wheel)luploadUsage:lupload --access-key=<my_access_key> --secret-access-key=<my_secret> --s3-bucket=<my_S3_bucket> --kms-key-id=<my_KMS_key> --s3-prefix=<my_S3_key_prefix> --endpoint-url=<my_endpoint_url>Effect: This will build (usingldist) and upload the resulting ZIP file to the specified S3 bucketaccess-keyanssecret-access-keyare optional (and DEPRECATED). The new method of setting these is by using the boto3 standard (https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html). This allows for several methods of granting AWS access, including through the use of roles and assumed roles. If provided, these are set toAWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYenvironment variables (respectively) in the localos.environ.kms-key-idis optional. If it is not provided, standard AES256 encryption will be useds3-prefixis optional. If it is not provided, the ZIP file will be uploaded to the root of the S3 bucketendpoint_urlis optional. If it is not provided, the default endpoint for the accessed account will be usedlupdateUsage:lupdate --function-names=<my_function1>,<my_function2>,<my_function3> --lambda-names=<my_name1>,<my_name2>,<my_name3> --layer-runtimes=python2.7,python3.6,python3.7 --region=<my_aws_region>Effect: This will update the AWS Lambda function or layer code for the listed functions/layers. Functions/layers may be function names, partial ARNs (in the case of a function name) and/or full ARNs.function-namesisDEPRECATED. Uselambda-namesinstead. Joined as asetwithlambda-names.lambda-namescontains the names of functions XOR layers, depending on the update type. Update type is sourced fromldistthroughlupload.layer-runtimesis optional, and can be one or more ofpython2.7|python3.6|python3.7, seperated by commas. Defaults to all three.Requires the use ofluploadas the S3 object uploaded is used as the function/layer code to update.regionis optional. If it is not provided, thenus-east-1will be used.This extension also adds three new attributes to the setup() function:lambda_functionUsage:lambda_function=<my_package>.<some_module>:<some_function>Effect: ldist will create a root-level python module named<package_name>_function.pywhere package_name is derived from thenameattribute. This created module will simply redefine your lambda handler function at the root-levellambda_moduleUsage:lambda_module=<some_module>Effect: ldist adds the named module to the list ofpy_modulesto install, normally at the root levellambda_packageUsage:lambda_package=<some_dir>Effect: ldist will copy the contents of the provided directory into the root level of the resulting lambda distribution. The provided directoryMUST NOThave an__init__.pyin it (e.g. - it can't be a real package)Allldistattributes can be used in the same setup() call. It is up to the user to ensure that you don't step all over yourself...Note that all other commands and attributes in setup.py will still work the way you expect them to.Enjoy!