A simple, per-project AWS Lambda Layer manager.
Project description
awslayer-manager
This a simple tool to build and upload your project requirements as an AWS Lambda Layer. It extracts the requirements
from your Pipfile and installs them into a separate directory which it's deployed from. This package also supports
working with the high performance mysqlclient
library by compiling it inside a docker container that closely mimics
the AWS Lambda environment and deploying it with the layer.
Installation
To install this package, run
pip install awslayer-manager
Requirements
- Requires your project to be using the
Serverless
framework - This package requires
Docker
if you're planning to work withmysqlclient
. If not, you can omit it.
Running
To initialize the layer in dev
environment, run
awslayer init dev
in the project directory. This will extract requirements from your Pipfile and create a serverless.yml inside the layer directory. Once the layer is initialized, run the following command:
awslayer deploy development
which will install all the requirements inside the layers/package
directory and deploy it using sls deploy
.
On environments
In order to attempt to match the CloudFormation your service will be deployed to, the script will search the current
working directory for the appropriate .env
file. If dev
or development
is specified, it will look for
.env.dev
or .env.development
(the two are interchangeable), and same holds for prod
and production
. If the
environment
is not specified, will first default to .env
and if not found, will search for a dev
env file.
Once that is done, add the following for each function in your project's serverless.yml:
functions:
func-name:
handler: src/handler.func-name
layers:
- "${cf:stack-name.ServiceNameLayerLambdaLayerQualifiedArn}"
where you can find the "ServiceNameLayerLambdaLayerQualifiedArn" identifier in the CloudFormation stack.
To update requirements and runtime, run:
awslayer update
NOTE: This package will create a layer
directory inside your project which I recommend adding to your
.gitignore file as it is fairly heavy (depending on the size of your requirements)
Contributing
Pull requests are welcome.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for awslayer_manager-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 665c2977913ebf7795446b8478ebaa1e3b790b70c658b6b38bea1d10b49cec94 |
|
MD5 | c306561420cc84a7ff7ad7155dac4948 |
|
BLAKE2b-256 | b1915708711927d9501369feebaedcdf7e06c7ae087db8a2538c66cdeb46cac7 |