I am trying to add the following Event Pattern to specific rule on Event Bridge
JavaScript
x
7
1
{
2
"account": ["0000000000000"],
3
"source": [{
4
"anything-but": ["some.source"]
5
}]
6
}
7
I tryed to use this python code
JavaScript
1
7
1
event_bridge.Rule(self, "send_to_firehose",
2
event_bus=remote_eventbridge,
3
event_pattern=event_bridge.EventPattern(
4
account=[self.account],
5
source=[{"anything-but":["some.source"]}],
6
..
7
but the “source” does not accept a json, only string array:
JavaScript
1
2
1
source: typing.Optional[typing.Sequence[builtins.str]] = None,
2
So I decided to try using dumps:
JavaScript
1
7
1
event_bridge.Rule(self, "send_to_firehose",
2
event_bus=remote_eventbridge,
3
event_pattern=event_bridge.EventPattern(
4
account=[self.account],
5
source=[json.dumps({"anything-but":["some.source"]})],
6
..
7
but does not work as expected, with result:
JavaScript
1
5
1
{
2
"account": ["0000000"],
3
"source": ["{"anything-but": ["some.source"]}"]
4
}
5
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