Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Pythonista Lambda microservice packager
-
Available as a Gist: deploy-to-lambda.py - https://gist.github.com/711970991ff701adc02335d79e5d0cf6
Playing with virtualenv on Pythonista was too challenging for me (see this thread: https://forum.omz-software.com/topic/3015/using-aws-boto3-library-with-pythonista). I created a script that packages the current script's directory and updates the Amazon Lambda with the same name as the directory.
To use:
- Install stash
- pip install boto3
- Create the function first in Amazon Lambda console
- Update the deploy script with your AWS ID, secret and region
- Create a directory with the same name as the function
- Place the handler function and other files in that directory
- Install any required libraries in the same directory (with pip install -d directory library)
- Add the deploy script as an action in the "wrench" menu
- After editing the script, run the deploy script
Script has no specific error handling whatsoever.
If I were to create a lot of services, this would be relatively easy to expand to check whether to update or create a function on Lambda, but for now you need to create the function in AWS Console first.
Note that you need to put an API endpoint in front of the service to make HTTP calls to it. If you want to turn it into a web service, you can configure the API to return Content-Type text/html - instructions here: https://kennbrodhagen.net/2016/01/31/how-to-return-html-from-aws-api-gateway-lambda/
As a related thing, my project has issues with httplib2 not behaving on Lambda - see this Stackoverflow question: http://stackoverflow.com/questions/39929374/aws-lambda-module-initialization-error-with-httplib2
Would appreciate if someone can help with that or at least independently verify the issue.
-
@mikael I'm actually currently working on the same thing for https://zeit.co/now
-
Does you working on it mean "now" will be available for Python as well? And of course easy to run from Pythonista.