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?
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