Potential bug with bucket eventing?

Hi folks,

So I’m setting up eventing on a new bucket to fire a Lambda. I want to create a new bucket (not attach events to an existing bucket). Following the documentation here I’ve been able to get everything working as expected using the following:

    events:
      - s3: ${self:custom.properties.${self:custom.environment}.bucketName}

However as soon as I add any complexity to it (filters, multiple events etc.) then the bucket doesn’t create. The rest of the stack is created fine and there are no error messages as the stack is being created or in the AWS cloud formation console, it’s as if the bucket has been removed from serverless.yml altogether.

examples:

    events:
      - s3:
        bucket: ${self:custom.properties.${self:custom.environment}.bucketName}
        event: s3:ObjectCreated:*
        rules:
          - prefix: master/
    events:
      - s3:
        bucket: ${self:custom.properties.${self:custom.environment}.bucketName}
        event: s3:ObjectRemoved:*
      - s3:
        bucket: ${self:custom.properties.${self:custom.environment}.bucketName}
        event: s3:ObjectCreated:*

I’m using the latest version of Serverless

Edit the indentation doesn’t seem to be preserved in this post, but in my code things are indented as per the documentation. If they weren’t indented correctly, there would be an error, right?

Hi Glenn,

I fixed your formatting :slight_smile:

If you’re using the same indentation here in your serverless.yaml then your indentation is wrong.

    events:
      - s3:
          bucket: ${self:custom.properties.${self:custom.environment}.bucketName}
          event: s3:ObjectRemoved:*
      - s3:
          bucket: ${self:custom.properties.${self:custom.environment}.bucketName}
          event: s3:ObjectCreated:*
1 Like

Hi Buggy,

Thanks very much for getting back to me. You were exactly right, the indentation was off.
I’m pretty frustrated with myself that I didn’t catch that, but relieved it’s working properly now.

Thanks again!

Glenn

1 Like