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

Multiple event definitions for existing S3 bucket #6477

Merged
merged 1 commit into from Aug 5, 2019
Merged

Conversation

pmuens
Copy link
Contributor

@pmuens pmuens commented Jul 30, 2019

What did you implement:

Closes #6461

Adds support to define multiple S3 events in one function.

How did you implement it:

Fix it and write regression tests.

How can we verify it:

Use the following serverless.yml file or run the S3 integration tests (which were updated as well).

service: test-${self:custom.idx}

provider:
  name: aws
  runtime: nodejs10.x
  versionFunctions: false

custom:
  idx: 0
  bucket: serverless-existing-s3-bucket # replace this with your bucket name

functions:
  created:
    handler: handler.hello
    events:
      - s3:
          bucket: ${self:custom.bucket}
          events: s3:ObjectCreated:*
          rules:
            - suffix: .txt
            - prefix: files
          existing: true
      - s3:
          bucket: ${self:custom.bucket}
          events: s3:ObjectCreated:*
          rules:
            - suffix: .pdf
            - prefix: files
          existing: true
  removed:
    handler: handler.hello
    events:
      - s3:
          bucket: ${self:custom.bucket}
          event: s3:ObjectRemoved:*
          rules:
            - suffix: .txt
            - prefix: files
          existing: true
      - s3:
          bucket: ${self:custom.bucket}
          event: s3:ObjectRemoved:*
          rules:
            - suffix: .pdf
            - prefix: files
          existing: true

The easiest way is to run the integration tests for S3 buckets.

Todos:

Note: Run npm run test-ci to run all validation checks on proposed changes

  • Write tests and confirm existing functionality is not broken.
    Validate via npm test
  • Ensure there are no lint errors.
    Validate via npm run lint-updated
    Note: Some reported issues can be automatically fixed by running npm run lint:fix
  • Ensure introduced changes match Prettier formatting.
    Validate via npm run prettier-check-updated
    Note: All reported issues can be automatically fixed by running npm run prettify-updated
  • Make sure code coverage hasn't dropped
  • Provide verification config / commands / resources
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: YES
Is it a breaking change?: NO

@pmuens pmuens merged commit a1976eb into master Aug 5, 2019
@pmuens pmuens deleted the existing-s3-multi branch August 5, 2019 14:32
@anshul1790
Copy link

Hi @pmuens, I have tagged you in the same issue which I am facing. It comes when I try to redeploy the YAML file again.
Error says: Failed to create resource. Configuration is ambiguously defined. Cannot have overlapping suffixes in two rules if the prefixes are overlapping for the same event type. See details in CloudWatch Log

#7536

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

Successfully merging this pull request may close these issues.

More than one s3 event failing deployment for existing s3 bucket.
3 participants