How to make EventBridge rule match on prefix AND suffix

1

When matching s3 events through eventbridge I would like to match on the prefix AND suffix of the key. The following results in an or match. { "detail-type": ["Object Created"], "source": ["aws.s3"], "detail": { "bucket": { "name": [some-bucket"] }, "object": {, "key": [{ "prefix": "some-prefix/" }, { "suffix": ".extention" }] } } }

Repeating the Key key one for prefix and one for suffix yields no results at all. Can someone help me out?

gefragt vor einem Jahr5846 Aufrufe
3 Antworten
1

Hey @pbouwdewijn,

I found a way to do it in one easy rule.

There is a wildcard filter option, so you can write something like this and it will work exactly as you want.

{
  "source": ["aws.s3"],
  "detail-type": ["Object Created"],
  "detail": {
    "bucket": {
      "name": ["some-bucket"]
    },
    "object": {
      "key": [{
        "wildcard": "some-prefix/*.extension"
      }]
    }
  }
}
bityob
beantwortet vor 6 Monaten
0

I am also encountering this issue and some things I found out:

So far, the following are the workarounds I can think of for my use case:

  • Use the regular S3 Event notification feature as it can limit based on prefix AND suffix - whenever I only need to publish the event to Lambda, SQS or SNS
  • If I really need to publish to EventBridge, I will create an S3 replication to another bucket and limit the scope to a prefix. That second bucket has EventBridge notification enabled and the event pattern filters the suffix
profile picture
joahna
beantwortet vor einem Jahr
0

I also encountered this issue, I was able to solve it by creating another Eventbus. My first event comes from s3 to the default EventBus and is filtered by prefix. I then trigger an event on a second Eventbus that filters by suffix, that targets my lambda

jswiney
beantwortet vor einem Jahr

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen