-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
103 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
layout: post | ||
title: "Lambada" | ||
short_description: "Python lambdas made easy, yes please." | ||
description: | | ||
At Superpedestrian we have really gotten into using AWS lambdas for | ||
ETL, batch processing, and other scheduled tasks so I made a nice | ||
framework for it. | ||
img: /img/posts/lambada/logo.png | ||
--- | ||
|
||
At [Superpedestrian](https://superpedestrian.com) we have really | ||
gotten into using AWS lambdas for ETL, batch processing, and other | ||
scheduled tasks, so I created | ||
[Lambada](https://lambada.readthedocs.io) as a nice framework for | ||
making collections of them inside a single repo with `build` time | ||
configuration via environment variables. | ||
|
||
Lambdas work great, are basically free, and have all sorts of great | ||
triggers. There are even interesting Web frameworks like | ||
[Chalice](https://github.com/awslabs/chalice) coming out, but what it | ||
lacks, at least for Python, is a nice way to package, manage | ||
dependencies, and bunch them together since they tend to be small and | ||
bunches of them share code. The nice part is that Rackspace already | ||
created a nice package and deployment system through | ||
[Lambda Uploader](https://pypi.python.org/pypi/lambda-uploader), so | ||
all that was really left was for me to make a framework for grouping | ||
them together in a single repo/project along with a way to do security | ||
sensitive configuration at build time via environment variable | ||
injection or yaml file. | ||
|
||
Lambada lets you use decorators similar to | ||
[Flask](http://flask.pocoo.org), to have one project with multiple | ||
Lambda functions in that can all be tested, run, and uploaded with a | ||
command line interface. The | ||
[quick start guide](http://lambada.readthedocs.io/en/latest/#quickstart) | ||
has more details, but basically, you can make a file that looks like: | ||
|
||
```python | ||
from lambada import Lambada | ||
|
||
chart = Lambada( | ||
handler='fouronthefloor.chart', | ||
role='arn:aws:iam:xxxxxxx:role/lambda', | ||
region='us-west-2', | ||
timeout=60, | ||
memory=128 | ||
) | ||
|
||
@chart.dancer | ||
def test_lambada(event, context): | ||
print('Event: {}'.format(event)) | ||
|
||
|
||
@chart.dancer( | ||
name='high_memory_test', | ||
memory=1024, | ||
requirements=['requirements.txt', 'xtra_requirements.txt'] | ||
) | ||
def cool_oneoff(event, context): | ||
print('Wow, so much memory! extra reqs!') | ||
|
||
|
||
@chart.dancer(memory=512, timeout=5) | ||
def bob_loblaw(event, _): | ||
print('Such a great reference!') | ||
``` | ||
|
||
and with a single `lambada upload` command create three lambdas in | ||
your AWS account with different requirements on time, memory, aws | ||
region, and even software dependencies. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.