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:
- A file is in a folder called
files/
(prefix: "files/"
) - The file is a CSV (
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"
}]
}
}
}
CodePudding user response:
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.