Miserlou / Zappa

Serverless Python
https://blog.zappa.io/
MIT License
11.89k stars 1.2k forks source link

Kappa Update Now Raises Event Issues #688

Closed mcrowson closed 7 years ago

mcrowson commented 7 years ago

Context

Scheduling events in S3 and SNS both raise warnings in the console. The events still appear to get created and work, but now a warning pops up in the console. ## Expected Behavior

Events should be scheduled and unscheduled without errors.

Actual Behavior

Kappa seems to be raising an error. The error differs for different different event sources.

Possible Fix

Revert Kappa to 0.6.0 to silence the warnings. This likely just hides the issue. Zappa 0.35.1 has that kappa version.

Steps to Reproduce

  1. Recent Zappa
  2. zappa schedule stage

Your Environment

bdecotes-pl commented 7 years ago

Perhaps related issue in scheduling s3 events:

From zappa update output:

Created s3:ObjectCreated:* event schedule for kit_parser.kit_event.kit_handler!

Which for my case now causes the following Exception to be raised when triggered by an s3:ObjectCreated:* event:

need more than 1 value to unpack: ValueError
Traceback (most recent call last):
File "/var/task/handler.py", line 499, in lambda_handler
return LambdaHandler.lambda_handler(event, context)
File "/var/task/handler.py", line 233, in lambda_handler
return handler.handler(event, context)
File "/var/task/handler.py", line 392, in handler
app_function = self.import_module_and_get_function(whole_function)
File "/var/task/handler.py", line 223, in import_module_and_get_function
module, function = whole_function.rsplit('.', 1)
ValueError: need more than 1 value to unpack

After adding logging just before this line 223 in handler.py, I get the following output:

whole function is: kit-parser-dev

When inspecting my s3 event configuration, the event name now triggered on my s3 bucket is the following:

arn:aws:lambda:us-east-1:<ACCOUNT_NUMBER>:function:kit-parser-dev

Manually editing the event name to the following:

kit-parser-dev:kit_parser.kit_event.kit_handler

or more generally:

{{project_name}}-{{stage_name}}:{{events_function_name}}

resolves the issue for me, and my event handler is correctly triggered on a new event invocation.

Relevant zappa settings:

"events": [{
      "function": "kit_parser.kit_event.kit_handler",
      "event_source": {
        "arn": "MY_BUCKET_ARN",
        "events": [
          "s3:ObjectCreated:*"
        ]
      }
    }]

Using Zappa version 0.37.1

Miserlou commented 7 years ago

phishkit

Bruhhhhh

bdecotes-pl commented 7 years ago

guess I could have sanitized everything :1st_place_medal:

Miserlou commented 7 years ago

Possibly fixed in 0.37.2, let me know if not and I'll reopen.

bdecotes-pl commented 7 years ago

Can confirm this issue is resolved for me with 0.37.2. Great work! 🎉

Miserlou commented 7 years ago

Good luck with your phishing!

bdecotes-pl commented 7 years ago

White-hat parsing only!