I need help in creating a event bridge rule pattern to capture an AWS event given below, with few variables mentioned under angle brackets <>
, requirement is to capture events where resources
object ARN
have suffix of sample
AND
prefix of product
. The solution should not be using wildcards:
Event:
{
"requestParameters": {
"bucketName": "mybucket",
"key": "product/<2023-11-11>/<10-31-04>/<my->sample.json",
},
"resources": [
{
"type": "AWS::S3::Object",
"ARN": "arn:aws:s3:::mybucket/product/<2023-11-11>/<10-31-04>/<my->sample.json"
},
{
"accountId": "1234567890",
"type": "AWS::S3::Bucket",
"ARN": "arn:aws:s3:::mybucket"
}
]
}
2
Answers
You can use a pattern like this:
In resources array, it will match any ARN that has the matching wildcard. The wildcard expects ARN to:
arn:aws:s3:::
product
sample
Sample event of EventBridge
References:
https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns-arrays.html
Amazon EventBridge: Match an object inside of an array
I’m not sure how you are getting events into the EventBridge, but I set up my S3 bucket to send events. Then I created the following rule and it works as expected:
The above works for any action, except GET.