Function s3 trigger with existing: true generates another lambda called custom-resources

Hello,
as title says, i’ve a function with a trigger on S3 using the new definition:

functions:
lambda:
handler: src/handler.handler
events:
  - s3:
      bucket: bucketName
      event: s3:ObjectCreated:*
      rules:
        - prefix: xml-texts/
        - suffix: .xml
      existing: true

The bucket already exists and i’m using the existing: true to avoid the error as described in

I’ll put my cloudFormation json too: https://pastebin.com/8v6GhunX

Is this a feature? a bug? someone knows why this happens?

Thanks!

The docs you link to specify : “Using the existing config will add an additional Lambda function and IAM Role to your stack. The Lambda function backs-up the Custom S3 Resource which is used to support existing S3 buckets.” :slight_smile:

1 Like

I’m blind I guess. Thanks for the reply!

I still think this is weird, I can connect an existing s3 bucket from the GUI, why can’t I just connect it is weird

This is all because of limitations in place by AWS on the CloudFormation which is what we use to deploy your resources into AWS as well as maintain state. Unfortunately the ability to connect to existing S3 buckets doesn’t exist in CloudFormation (strange, I know) so the only way left for us to add that feature is to support it via a feature provided by AWS know as Custom CloudFormation Resources.

We know this isn’t perfect, but those are some of the limits we work under :slight_smile:

1 Like

Thank you for the clarification

I was sure that the “problem” is in AWS