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"
}
]
}
You can use a pattern like this:
{
"resources": {
"ARN": [{
"wildcard": "arn:aws:s3:::*/product/*/*/*sample.*"
}]
}
}
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
{
"id": "234234",
"account": "23423423",
"source": "asdfsf",
"time": "2016-01-10T01:29:23Z",
"region": "ap-south-1",
"detail-type": "234234",
"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"
}
]
}
References:
https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns-arrays.html