Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3 triggers apply incorrectly with multiple stages using the same bucket #2111

Open
arcadecoffee opened this issue Jun 8, 2020 · 2 comments

Comments

@arcadecoffee
Copy link

Context

If multiple stages use the same S3 bucket and events but with different prefixes, deployments, undeployments, schedules apply the S3 bucket events incorrectly.

Expected Behavior

Each stage should be capable of deploying it's own triggers and underlying only its own triggers.

Actual Behavior

The first deployment works correctly but subsequent deployments do not add the events for those stages. Undeployment of any stage deletes all events if the missing events have been added manually.

Possible Fix

During deployment or undeployment, bucket notification configurations in place as identified by trigger id should be compared to desired state (current state plus or minus event in question) and resulting configuration applied to the bucket.

Steps to Reproduce

Using zappa_settings.json below:

  1. zappa deploy dev
  2. Note trigger on lambda and event on S3 bucket
  3. zappa deploy stage
  4. Note the lack of the trigger on lambda and event on S3 bucket

Your Environment

zappa_settings.json:

{
  "dev": {
    "app_function": "example.app",
    "aws_region": "us-east-1",
    "profile_name": "default",
    "project_name": "zappa-example",
    "runtime": "python3.7",
    "s3_bucket": "zappa-123456",
    "events": [
      {
        "function": "example.dev_app",
        "event_source": {
          "arn": "arn:aws:s3:::bucketname1234",
          "key_filters": [
            {
              "type": "prefix",
              "value": "dev"
            }
          ],
          "events": [
            "s3:ObjectCreated:*"
          ]
        }
      }
    ]
  },
  "stage": {
    "app_function": "example.app",
    "aws_region": "us-east-1",
    "profile_name": "default",
    "project_name": "zappa-example",
    "runtime": "python3.7",
    "s3_bucket": "zappa-123456",
    "events": [
      {
        "function": "example.stage_app",
        "event_source": {
          "arn": "arn:aws:s3:::bucketname1234",
          "key_filters": [
            {
              "type": "prefix",
              "value": "stage"
            }
          ],
          "events": [
            "s3:ObjectCreated:*"
          ]
        }
      }
    ]
  },
  "prod": {
    "app_function": "example.app",
    "aws_region": "us-east-1",
    "profile_name": "default",
    "project_name": "zappa-example",
    "runtime": "python3.7",
    "s3_bucket": "zappa-123456",
    "events": [
      {
        "function": "example.app",
        "event_source": {
          "arn": "arn:aws:s3:::bucketname1234",
          "key_filters": [
            {
              "type": "prefix",
              "value": "prod"
            }
          ],
          "events": [
            "s3:ObjectCreated:*"
          ]
        }
      }
    ]
  }
}
@arcadecoffee
Copy link
Author

This is fixed here : #2126

@eversdyk
Copy link

Reviewed fix #2126 which prevents unintended/accidental deletion of S3 event triggers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants