Event Bridge rule match on two specific directories from the same S3 Bucket

0

I want an Event Bridge rule to match on two different directories (prefixes) of the same S3 Bucket when a file is uploaded to any of the directories.

If I put two prefix objects under detail.object.key the rule only matches on the last one, as per the event pattern below:

{ 
  "source": ["aws.s3"],
  "detail-type": ["Object Created"],
  "detail": { 
    "bucket": { "name": ["some-bucket"] },
    "object": {
      "key": [
        { "prefix": "some-prefix/" },
        { "prefix": "some-other-prefix/" }
      ] 
    } 
  } 
}

The documentation is unclear about how to accomplish this.

1 Antwort
1
Akzeptierte Antwort

I found a way to do it using Content-based filtering with $or matching.

https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns-content-based-filtering.html#eb-filtering-complex-example-or

Documentation is still unclear about the specific use case but after a couple of trials and errors I got it working by declaring the event pattern like this:

{
  "source": ["aws.s3"],
  "detail-type": ["Object Created"],
  "detail": {
    "bucket": {
      "name": ["some-bucket"]
    },
    "$or": [
      {
        "object": {
          "key": [{
            "prefix": "some-prefix/"
          }]
        }
      },
      {
        "object": {
          "key": [{
            "prefix": "some-other-prefix/"
          }]
        }
      }
    ]
  }
}

Hope it helps!

profile picture
jigle
beantwortet vor einem Monat
profile picture
EXPERTE
überprüft vor einem Monat

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