1

I am trying to find a way to somehow capture events that do not match any rule in any given event bus. No luck so far.

So I thought I should try creating explict rules to achieve the same.

I have the below pattern which works if all 3 values branchPlant, marketCode & sourceInstance do not match.

{
  "detail-type": ["ShipConfirmation"],
  "detail": {
    "Header": {
      "branchPlant": [{
        "anything-but": ["6480999"]
      }],
      "marketCode": [{
        "anything-but": ["PHL"]
      }],
      "sourceInstance": [{
        "anything-but": ["ShipConfirmation"]
      }]
    }
  }
}

However, I want the rule to be triggered if any one of them don't match. Is there a way to implement an OR condition like solution here?

Aniket Kapse
  • 315
  • 3
  • 20
  • i couldn't get what you are describing above to work for my use case where i did only want to match when 2 values both did not match their respective patterns. whats most annoying is that in the testing tool that AWS provide the pattern matched successfully but when deployed it didn't. – randal25 Nov 17 '22 at 13:34

1 Answers1

0

https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html

"For an event pattern to match an event, the event must contain all the field names listed in the event pattern. The field names must also appear in the event with the same nesting structure."

I think you can achieve your goal with 3 rules - each of them with just one pattern.

petrch
  • 1,807
  • 15
  • 19
  • Well I thought of this but it won't be possible considering it will increase the number of rules by 3 fold. Harder to manage since I have more that 10 rules. – Aniket Kapse Apr 05 '22 at 11:08
  • 1
    Let you consider to generate them - it's not that hard and less error-prone. You can use CDK or just generate json/yaml CloudFormation with some simple templating. On large scale you don't really want to write CloudFormation manually - but there are alternatives to Terraform, you don't have to go that far. – petrch Apr 05 '22 at 16:10