nikhilalmeida
nikhilalmeida

Reputation: 111

Can zappa be used to run functions directly (non wsgi apps)

zappa can easily be used to run flask apps. But it creates just one lambda function per app. Can I have a separate lambda function for each python function I declare?

Upvotes: 11

Views: 2788

Answers (2)

mislavcimpersak
mislavcimpersak

Reputation: 3020

Since this is the first SO result that you get when searching for zappa for non-wsgi I'll share my 2 cents.

If you just want use Zappa to deploy to AWS Lambda and be able to invoke your function without actually using WSGI you can do something like this:

myapp.py

def foo(event, context):
    print('foo bar')
    return 'lambda triggered!'

zappa_settings.json

{
    "dev": {
        "lambda_handler": "myapp.foo",
        ...
    }
}

Now go to your AWS Lambda console in browser and click Test and see the function being triggered.

Upvotes: 14

Rahul Sekar
Rahul Sekar

Reputation: 123

You can create 'command' trigger events like below and zappa will invoke your python function:

{ 
  "command": "mymodule.myfunction"
}

Your app doesn't have to be a wsgi app. You can create each lambda function individually & upload the same zappa package as zip on each of them.

Upvotes: 5

Related Questions