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

Support for S3:Events Prefix and Suffix Rules #27

Closed
malcyL opened this issue Jun 4, 2018 · 5 comments
Closed

Support for S3:Events Prefix and Suffix Rules #27

malcyL opened this issue Jun 4, 2018 · 5 comments

Comments

@malcyL
Copy link

malcyL commented Jun 4, 2018

Serverless allows for the setting of prefix and suffix rules on S3 Events:

https://serverless.com/framework/docs/providers/aws/events/s3#setting-filter-rules

functions:
  users:
    handler: incoming.handler
    events:
      - s3:
          bucket: mybucket
          event: s3:ObjectCreated:*
          rules:
            - prefix: incoming/
            - suffix: .zip

I think serverless-s3-local is ignoring these rules?

My use case is an existing system which changes the key of a file after it's completed processing. For example, a file is uploaded to s3 with a bucket and key: s3://mybucket/incoming/file1.zip and then after processing it is moved to s3://mybucket/processed/file1.zip.

When running locally with serverless-s3-local the handler is triggered twice, once when it is initially created and again when the key is changed. When deployed to AWS this doesn't happen as the prefix and suffix rules are applied.

@ar90n
Copy link
Owner

ar90n commented Jun 8, 2018

Hi @malcyL
Thanks for your report.
Now, serverless-s3-local doesn't support these rules.
But I decided to try to support this function.
Please wait for a while.

@ar90n
Copy link
Owner

ar90n commented Jun 12, 2018

Hi @malcyL
I implemented this feature at v0.3.6.
Please try it !

@malcyL
Copy link
Author

malcyL commented Jun 13, 2018

Hi @ar90n

I've tested your new release this morning and it's working as expected.

The lambda is triggered when the file is first created and the key matches the rules. After processing when we change the key of the file, the lambda is no longer triggered because the new key doesn't match the rules.

I've also tested with multiple lambda's all working with different prefixes. i.e. Lambda 1 processing files from s3://mybucket/images/incoming and Lambda 2 processing files from s3://mybucket/data/incoming. Previously, incoming files would trigger both the lambda's. Now only the correct lambda is triggered.

I'm happy for this issue to be closed, but I'll leave it for you to do.

Thank you so much for turning this feature request around so quickly. That's very impressive.

@ar90n
Copy link
Owner

ar90n commented Jun 13, 2018

@malcyL
That sounds good !
I'm glad to help you with serverless-s3-local.
If you meet any problem, please inform of me.
I'll try to solve the issues as possible.

@ar90n ar90n closed this as completed Jun 13, 2018
@fffan64
Copy link

fffan64 commented Apr 23, 2020

hello,

having same problem in latest version 0.5.4, look like the issue is back !

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

3 participants