user2249827
user2249827

Reputation: 11

How do I subscribe multiple S3 Lambda triggers to an existing bucket?

For example, we have three event subscribers (two for S3, one for HTTP.)

Currently, I am able to hit HTTP endpoint, However, unable to trigger s3 event as lambda is not attached to Bucket properties under Event section.

functions:
   name: function-name
   handler: function-handler.handle
   events:
      - existingS3:
         bucket: abc-dev
         events:
            - s3:ObjectCreated:*
         rules:
            - prefix: folder/my-folder
      - existingS3:
         bucket: abc-dev
         events:
            - s3:ObjectCreated:*
         rules:
            - prefix: folder/my-folder-env
      - http:
         path: abc/xyz/
         method: post
         async: true
         private: true

Upvotes: 1

Views: 560

Answers (1)

Gareth McCumskey
Gareth McCumskey

Reputation: 1540

The Serverless Framework added support for existing S3 buckets last year. All you need to do is add a regular S3 event just like normal as documented but add the property existing: true to the configuration of the event.

https://www.serverless.com/framework/docs/providers/aws/events/s3#using-existing-buckets

Upvotes: 1

Related Questions