zappa / Zappa

Serverless Python
https://zappa.ws/zappa
MIT License
3.35k stars 362 forks source link

[Migrated] Multiple event triggers generate duplicate copies of the first event trigger defined #504

Closed jneves closed 7 months ago

jneves commented 3 years ago

Originally from: https://github.com/Miserlou/Zappa/issues/1319 by philvarner

Context

When I define event triggers like the following (contrived from my real usage):

base_stage:
...
  events:
    - function: summary_generator.generate
      event_source:
        arn:  arn:aws:s3:::some-bucket-us-east-2
        events:
          - s3:ObjectCreated:Post
    - function: summary_generator.generate2
      event_source:
        arn:  arn:aws:s3:::some-bucket-us-east-2
        events:
          - s3:ObjectCreated:Put

I get the following output on update:

Removed event summary_generator.generate (['s3:ObjectCreated:Post']).
Removed event summary_generator.generate2 (['s3:ObjectCreated:Put']).
Created s3:ObjectCreated:Post event schedule for summary_generator.generate!
s3:ObjectCreated:Put event schedule for summary_generator.generate2 already exists - Nothing to do here.

However, what actually happens is I get two event triggers defined on the lambda for the first event trigger definition. The number of event triggers created is equal to the number of event triggers defined (rather than the number of deploys).

This may be caused by my adding the second even definition after the initial deploy. It may work correctly if both events are defined when the zappa project is first deployed, but I have not tested that scenario.

Expected Behavior

Two event triggers are created according to my definitions.

Actual Behavior

Two event triggers are created, both matching the first event trigger definition.

Possible Fix

I haven't debugged this very far, but my guess is that the problem lies in the logic in zappa.utilitites.add_event_source, where there's a comment "# TODO: Detect changes in config and refine exists algorithm".

Steps to Reproduce

See above example of event definitions.

Your Environment

skims-ella-travelstead commented 1 year ago

Hello, is there any update on this? Seems like it still cant have multiple event notification for a single bucket with different prefixes.

s3:ObjectCreated:Put event schedule for test-job already exists - Nothing to do here.

github-actions[bot] commented 8 months ago

Hi there! Unfortunately, this Issue has not seen any activity for at least 90 days. If the Issue is still relevant to the latest version of Zappa, please comment within the next 10 days if you wish to keep it open. Otherwise, it will be automatically closed.

github-actions[bot] commented 7 months ago

Hi there! Unfortunately, this Issue was automatically closed as it had not seen any activity in at least 100 days. If the Issue is still relevant to the latest version of Zappa, please open a new Issue.