Reputation: 1
I have an EventBridge rule that triggers a lambda function whenever a .txt or .csv file is uploaded to a specific s3 bucket. I want to modify the rule so that it wont trigger for files with certain pattern. eg : files that start with "abc". The following is my event pattern :
{
"detail": {
"eventName": [
"PutObject",
"CopyObject",
"CompleteMultipartUpload"
],
"eventSource": [
"s3.amazonaws.com"
],
"requestParameters": {
"bucketName": [
<bucket_name>
],
"key": [
{
"wildcard": "folder_name/*/*.csv"
},
{
"wildcard": "folder_name/*/*.txt"
}
]
}
},
"detail-type": [
"AWS API Call via CloudTrail"
],
"source": [
"aws.s3"
]
}
How can I achieve this ?
Upvotes: 0
Views: 404
Reputation: 11
Echoing what @Michael Gasch said above. I would try to add "anything-but" similar to what is below. Note that you can't have multiple values in an anything-but matching rule, and I'm not sure if it will support wildcard matching which is what it looks like you want to do with "folder_name/*".
{
"detail": {
"eventName": [
"PutObject",
"CopyObject",
"CompleteMultipartUpload"
],
"eventSource": [
"s3.amazonaws.com"
],
"requestParameters": {
"bucketName": [
<bucket_name>
],
"key": [
{
"wildcard": "folder_name/*/*.csv"
},
{
"wildcard": "folder_name/*/*.txt"
},
{
"anything-but": {"prefix": "abc"}
}
]
}
},
"detail-type": [
"AWS API Call via CloudTrail"
],
"source": [
"aws.s3"
]
}
Upvotes: 0
Reputation: 501
You could try with anything-but
https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns-content-based-filtering.html#eb-filtering-anything-but
Upvotes: 0