'How to add trigger for s3 event?

How to add a trigger for an s3 folder?

I can add triggers for a bucket from my serverless configuration.

But not sure how to add a trigger for a folder path?

    events:
      - s3:
          bucket: files          
          event: s3:ObjectCreated:*
          existing: true


Solution 1:[1]

You would have to setup a prefix as shown in the docs:

    events:
      - s3:
          bucket: files          
          event: s3:ObjectCreated:*
          existing: true
          rules:
            - prefix: your-folder/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Marcin