omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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

    Pythonista
    2
    3
    3394
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • mikael
      mikael last edited by

      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.

      Webmaster4o 1 Reply Last reply Reply Quote 1
      • Webmaster4o
        Webmaster4o @mikael last edited by

        @mikael I'm actually currently working on the same thing for https://zeit.co/now

        1 Reply Last reply Reply Quote 0
        • mikael
          mikael last edited by

          Does you working on it mean "now" will be available for Python as well? And of course easy to run from Pythonista.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors