Using "existing: true" on a s3 event throws "Unable to validate the following destination configurations"

Hello everyone,

We used to use the parameter existing: true in ours functions to attach Event notifications to ours S3 buckets.
But now when I try to deploy a new stack using this parameters, I get the following error:

An error occurred: EventDashs3CustomS31 - Received response status [FAILED] from custom resource. Message returned: Unable to validate the following destination configurations See details in CloudWatch Log: 2021/07/01/[$LATEST]f75aa563de5a4bfba7648d2369650888 (RequestId: 6fd0e4db-f0b2-4b4f-ba91-d76eeb1fb888).

The serverless config:

environment:
    BUCKET_UPLOAD_CSV: my_upload_bucket
  iamRoleStatements:
    - Effect: Allow
      Action:
        - s3:ListBucket
        - s3:PutObject
        - s3:GetObject
        - s3:DeleteObject
        - "s3:GetBucketNotification"
        - "s3:PutBucketNotification"
      Resource: "arn:aws:s3:::${self:provider.environment.BUCKET_UPLOAD_CSV}/*"
functions:
  event-s3:
    runtime: nodejs14.x
    handler: index.handler
    tags: ${self:custom.tags}
    timeout: 900
    memorySize: 128
    events:
      - s3:
          bucket: ${self:provider.environment.BUCKET_UPLOAD_CSV}
          event: s3:ObjectCreated:*
          existing: true
          rules:
            - prefix: public/upload

Any ideas? I read some posts online about this error, and I tried things like:

  • Deploying the lambda first and attaching the notification event after.
  • Giving lambda:InvokeFunction as a IAM permission to the bucket.
  • Tried to use the serverless-plugin-existing-s3

But, no success so far.

Iā€™m currently using the latest version of serverless (2.50)

Regards

1 Like

Having exactly the same problem. Adding this S3 event works sometimes but other times it fails like described by OP.