Skip to content
Advertisement

Event Pattern rule “anything-but” using CDK

I am trying to add the following Event Pattern to specific rule on Event Bridge

{
  "account": ["0000000000000"],
  "source": [{
    "anything-but": ["some.source"]
  }]
}

I tryed to use this python code

event_bridge.Rule(self, "send_to_firehose",
                  event_bus=remote_eventbridge,
                  event_pattern=event_bridge.EventPattern(
                  account=[self.account],
                  source=[{"anything-but":["some.source"]}],
                  .....

but the “source” does not accept a json, only string array:

 source: typing.Optional[typing.Sequence[builtins.str]] = None,

So I decided to try using dumps:

event_bridge.Rule(self, "send_to_firehose",
                  event_bus=remote_eventbridge,
                  event_pattern=event_bridge.EventPattern(
                  account=[self.account],
                  source=[json.dumps({"anything-but":["some.source"]})],
                  .....

but does not work as expected, with result:

{
  "account": ["0000000"],
  "source": ["{"anything-but": ["some.source"]}"]
}

Is there any way to add “anything-but” rule in source, or this is a cdk limitation?

Advertisement

Answer

Just figure out, this is a limitation in current version of CDK.

It should be fixed with this PR from CDK Team: https://github.com/aws/aws-cdk/pull/21310

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement