Adding Lambda event handler to S3 Bucket that already exists in service


#1

Hi,

I have a Serverless stack in production with and S3 Bucket.
I wish to add a handler for s3:ObjectCreated events in a folder in this bucket.

But when I try and add the following:

  handleAbcResponseFile:
    handler: api/myStuff.handleAbcResponseFile
    events:
      - s3:
          bucket: ${self:custom.stage}-core.mydomain.com
          event: s3.ObjectCreated:*
          rules:
              - prefix: My/Sub/dir/
              - suffix: .csv

It attempts to create the dev-core.mydomain.com bucket and throws an error because it already exists.

Is there a way to add event handlers to a bucket that was created previously(in this stack)?
or do I need to drop and the bucket and re-create it?

Which would suck because there’s are ton of files in the bucket already.

Thanks in advance for any advice.