Data Skeptic
Data Skeptic

Reputation: 164

How can I add a Lambda Trigger without erasing other triggers?

I have an S3 bucket that I'm dropping heterogeneous files into. Each file in in a specific folder (i.e. key="typeA/content.json") and each folder is to trigger a different Lambda Function.

I'm using this command:

aws s3api put-bucket-notification-configuration --bucket mybucket --notification-configuration file://notification.json

And my notification.json file looks like this:

{ "LambdaFunctionConfigurations": [ { "LambdaFunctionArn": "arn:aws:lambda:us-east-1:085318171245:function:myfunction", "Events": ["s3:ObjectCreated:*"], "Id": "lkjlkj", "Filter": { "Key": { "FilterRules": [ {"Name": "prefix", "Value": "typeA"}, {"Name": "suffix", "Value": "content.json"} ] } } } ] }

This command works great for the first trigger I create. However, when I attempt to add a different trigger to a different LambdaFunctionArn (for the "typeB" prefix), the first Trigger is erased.

I am aware that the prefix+suffix must be unique and I have confirmed that this is not the issue.

I could first lookup all existing Triggers, append the new one, and then send back the full list, but this seems inefficient.

How can I just append one more Trigger?

Upvotes: 1

Views: 538

Answers (1)

omuthu
omuthu

Reputation: 6333

Looks like there is only one lambda association possible for S3 Object Creation event.

https://forums.aws.amazon.com/message.jspa?messageID=600330

Try S3 fanout where you send the S3 notification to an SNS Topic and there can multiple lambda consumers for SNS to process them.

https://aws.amazon.com/blogs/compute/fanout-s3-event-notifications-to-multiple-endpoints/

Hope this helps.

Upvotes: 1

Related Questions