Reputation: 407
I have an Event Bridge rule created where when I drop a file into an S3 bucket it will trigger a Step function.
I only want to trigger this rule when:
files/
(prefix: "files/"
)suffix: ".csv"
)However this rule is being triggered for any files regardless of their suffix and prefix. For instance I dropped a .pdf file in and it triggered the step function.
{
"detail-type": ["Object Created"],
"source": ["aws.s3"],
"detail": {
"bucket": {
"name": ["my-files-bucket"]
},
"object": {,
"key": [{
"prefix": "files/"
}, {
"suffix": ".csv"
}]
}
}
}
Upvotes: 3
Views: 3174
Reputation: 58
I have found a workaround to this. EventBridge now supports wildcards for key matching: Filtering events in Amazon EventBridge with wildcard pattern matching
Here is an example of solution (this also shows a scenario where you want to match multiple file types):
{
"source": ["aws.s3"],
"detail-type": ["Object Created"],
"detail": {
"bucket": {
"name": ["my-files-bucket"]
},
"object": {
"key": [{
"wildcard": "files/*.csv"
}, {
"wildcard": "files/*.pdf"
}]
}
}
}
Upvotes: 3
Reputation: 25649
This is the expected behaviour. EventBridge treats multiple values in brackets as an OR condition. Events will match your pattern if the object key begins with files/
OR ends with .csv
.
As far as I know, it's not possible to apply an AND condition to a single field.
Upvotes: 5