The AWS Lambda Function Manager
You're probably wondering what lfm is good for. Well, suppose you wake up one day and suddenly realize you need a Lambda function for AES encryption. You could roll your own solution, but ain't nobody got time for that. So you do a quick GitHub search and -- lo and behold -- there's this beauty.
Normally you'd have to clone the repo, install its dependencies, zip it up, and deploy it yourself. But with lfm, you can just do:
$ lfm deploy gh:willyg302/aws-lambda-aes --role execution_role_arn
Yup, and it works with local directories too:
$ lfm deploy my-sweet-function/ --role execution_role_arn
$ lfm deploy --role execution_role_arn # Will deploy working directory
Only got a single file? No problemo:
$ lfm deploy awesome-sauce.js --role execution_role_arn
In addition, you can override any of the usual config (see lfm deploy -h
for options).
The magic of lfm is a special file called .lambda.yml
at the root of a repo or directory. It looks something like this:
config:
FunctionName: my-awesome-sauce-function
Handler: index.handler
Mode: event
Runtime: nodejs
Description: This function will blow your mind
Role: execution_role_arn # Not recommended, especially in a public repo
install: npm install --production
ignore:
- test/
- README.md
config
holds all that junk you're used to passing to upload-function
, so you don't have to type it out any more. Note that any config you provide to lfm deploy
will override the values in this file.
install
is a single command for installing dependencies before zipping up the function. In this example, we want to install some Node modules so we use npm install --production
, but you can just as well shell out to make
for more heavy lifting.
ignore
is a list of paths that will not be added to the zip file.
NOTE: You don't need a .lambda.yml
to be able to use lfm; it's just easier that way. Without the config file, you'll have to provide all the required config as command-line arguments.
Cool beans. Just stick that config in your YAML front matter:
---
FunctionName: hello-world
Handler: hello-world.handler
Mode: event
Runtime: nodejs
Description: My awesome Hello World function!
---
console.log('Loading event');
exports.handler = function(event, context) {
console.log("value1 = " + event.key1);
console.log("value2 = " + event.key2);
console.log("value3 = " + event.key3);
context.done(null, "Hello World");
};
Save this in hello-world.js
and you're good to go! It's probably worth mentioning that since you have just a single file, you won't be doing any installing or ignoring of files or anything like that. So the only stuff that goes in the YAML is what you'd pass to upload-function
.
lfm is still in early development, so don't expect to be finding it on PyPI. You can grab it with a quick pip install git+https://github.com/willyg302/lfm.git@master
.
If, like Rust, lfm decides to eat your laundry, please file an issue.
Don't fret, we hear you! There are currently plans for the following features:
- GitHub Gists: Give a Gist URL, get a running Lambda function
- Webhooks: A bit far-fetched, but wouldn't it be cool to
git push
and kick off a Lambda deploy?
Call tests with python setup.py test
.