Open cscetbon opened 7 years ago
Thanks for reporting. Does the same behavior happen if you remove the events
key-value from your settings? That decorator is supposed to handle that seamlessly.
@Miserlou, I had to add the event cause I was getting the following error :
[1495411919625] Traceback (most recent call last):
[1495411919625] File "/private/var/folders/zw/v7zl8lnd3kx6wt6xvpnpsq6nzlczyd/T/pip-build-7CyJnE/flask/flask/app.py", line 1982, in wsgi_app
[1495411919625] File "/private/var/folders/zw/v7zl8lnd3kx6wt6xvpnpsq6nzlczyd/T/pip-build-7CyJnE/flask/flask/app.py", line 1614, in full_dispatch_request
[1495411919625] File "/private/var/folders/zw/v7zl8lnd3kx6wt6xvpnpsq6nzlczyd/T/pip-build-7CyJnE/flask/flask/app.py", line 1517, in handle_user_exception
[1495411919625] File "/private/var/folders/zw/v7zl8lnd3kx6wt6xvpnpsq6nzlczyd/T/pip-build-7CyJnE/flask/flask/app.py", line 1612, in full_dispatch_request
[1495411919625] File "/private/var/folders/zw/v7zl8lnd3kx6wt6xvpnpsq6nzlczyd/T/pip-build-7CyJnE/flask/flask/app.py", line 1598, in dispatch_request
[1495411919625] File "/var/task/test.py", line 16, in order_pie
[1495411919625] make_pie()
[1495411919625] File "/private/var/folders/zw/v7zl8lnd3kx6wt6xvpnpsq6nzlczyd/T/pip-build-9iUMx6/zappa/zappa/async.py", line 306, in _run_async
[1495411919625] File "/private/var/folders/zw/v7zl8lnd3kx6wt6xvpnpsq6nzlczyd/T/pip-build-9iUMx6/zappa/zappa/async.py", line 141, in send
[1495411919625] File "/private/var/folders/zw/v7zl8lnd3kx6wt6xvpnpsq6nzlczyd/T/pip-build-9iUMx6/zappa/zappa/async.py", line 195, in _send
[1495411919625] File "/var/runtime/botocore/client.py", line 253, in _api_call
[1495411919625] return self._make_api_call(operation_name, kwargs)
[1495411919625] File "/var/runtime/botocore/client.py", line 557, in _make_api_call
[1495411919625] raise error_class(parsed_response, operation_name)
[1495411919625] NotFoundException: An error occurred (NotFound) when calling the Publish operation: Topic does not exist
Are you saying that when we use task_sns, Zappa is supposed to create one SNS topic per task ? or one SNS topic for the whole app ? Is it possible to have the same function triggered by SNS events and by another function using task_sns ? or should I implement it using 2 different functions calling the same code ?
Hey @Miserlou, were you able to find out what's going on ?
@Miserlou so digging into the issue, I found that I needed to add "async_source": "sns"
to my settings to have the SNS topic created. But then I get a new issue that is :
Cannot find a function to process the triggered event
This error happens when the lambda receives the SNS event. It does https://github.com/Miserlou/Zappa/blob/master/zappa/handler.py#L298-L299
So you see that it expects the event to be defined in settings. It should instead use the command in u'Message': u'{"args": [], "command": "zappa.async.route_sns_task", "task_path": "test.make_pie", "kwargs": {}}'
or return task_path
which is the fastest.
something similar to https://github.com/Miserlou/Zappa/blob/master/zappa/handler.py#L331-L339 should be done in case Message
contains a command or task_path in records[0].Message
. But to do it, we need to load the Json string into a python object as in case of an SNS event, the command value is not directly accessible. That's why I'm thinking that we should directly use task_path
cause otherwise we would load the Json string twice
Trying to follow the documentation, I've met an issue when trying to use an SNS event.
A workaround is to add region and account id, but we shouldn't have to do it and that's why I consider it as a Bug.
## Expected BehaviorI should not get any error and the app should be deployed.
Actual Behavior
see https://pastebin.com/raw/K9AwXHbf
Possible Fix
Steps to Reproduce
use the following sample code test.py :
with zappa_settings.json similar to the one provided below.
Your Environment
pip freeze
:zappa_settings.py
: