简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM