can't we have like this? ```const bucket = new Buc...
# help
s
can't we have like this?
Copy code
const bucket = new Bucket(this, "Bucket", {
  notifications: [
    {
      function: "src/notification1.main",
      notificationProps: {
        events: [EventType.OBJECT_CREATED],
      },
    },
    {
      function: "src/notification2.main",
      notificationProps: {
        events: [EventType.OBJECT_CREATED],
      },
    },
  ],
});
Or what is the best way to call different functions on same event?
t
you can use
bucket.addNotification
I believe
s
I wanted to trigger separately on same s3 EventType
@Frank
t
Yes you can use that function to add another handler to the same eventtype
s
i tried but deploy failed
t
Can you share your code and your error
s
BucketNotificationsC3B6C972 Received response status [FAILED] from custom resource. Message returned: Error: An error occurred (InvalidArgument) when calling the PutBucketNotificationConfiguration operation: Configuration is ambiguously defined. Cannot have overlapping suffixes in two rules if the prefixes are overlapping for the same event type.. See the details in CloudWatch Log Stream: 2021/11/02/[$LATEST]c33ea1245a28438b9e2fb2321208ad26 (RequestId: 04fd7c9f-9995-4ea2-b2b5-d23443a6b039)
Copy code
bucket.addNotifications(this, [
      {
        function: {
          handler: "src/test-one.main",
        },
        notificationProps: {
          events: [s3.EventType.OBJECT_CREATED],
        },
      },
      {
        function: {
          handler: "src/test-two.main",
        },
        notificationProps: {
          events: [s3.EventType.OBJECT_CREATED],
        },
      },
    ]);
@thdxr Here's the error and the code
t
So it looks like you cannot have two triggers for the same event type without different prefix filters
Is there a reason you want to have two? Typically you should send it to something like eventbridge and then configure multiple rules there
s
I'm just started to work with these. I didn't know there is alternative ways to do such thing 😐
I'm new to serverless & AWS
t
No worries 🙂 Basically you can only have one trigger. Which means whatever is receiving that trigger should do both pieces of work you want to do
f
@Sahan Amadoruge ah yeah you can only have 1 trigger per notification type. You can add a Topic trigger, which in turn have 2 subscribers.
And you can cofigure subscribers to a topic like this https://docs.serverless-stack.com/constructs/Topic#using-the-minimal-config
s
@Frank Thank you . I was trying something like this.