Aws-cdk: EventBridge matcher support

Created on 10 Feb 2020  路  6Comments  路  Source: aws/aws-cdk

EventBridge had release improved set of matchers for it's Pattern by end of 2019. This had been described in detail in Blog post and Documentation page

The current implementation of EventPattern needs to be changed to address it: https://github.com/aws/aws-cdk/blob/master/packages/@aws-cdk/aws-events/lib/event-pattern.ts#L30

The operators to be supported:

  • Prefix
  • AnythingBut
  • Numeric
  • Exists

Use Case

The use case is to allow customer use the full capabilities of EventBridge pattern matching through CDK.

Proposed Solution

This is to be discuss, I would like to expand the existing way using the union like structure that would convert the existing definition from i.e.:

readonly source?: string[]

into:

readonly source?: string[] | Prefix | AnythingBut | Exists | Numeric 

Providing the this can be supported by CDK transcompilation.

Other

  • [X] :wave: I may be able to implement this feature request
  • [X] :warning: This feature might incur a breaking change

This is a :rocket: Feature Request

@aws-cdaws-events efformedium feature-request in-progress p2

Most helpful comment

Apparently this works for now:

source: [ { prefix: "your.prefix.here"} ] as any[]

All 6 comments

We don't support unions in our transcompilation. We usually follow the pattern of a union-like class with static factory functions.

Then I don't see other way to support this without changing the types from

readonly attribute?: string[]

into

readonly attribute?: any[]

In language like Java this is going to be backward compatible change as the array are covariant, though not sure about other cases.

Note that https://github.com/aws/aws-cdk/issues/5205 is still relevant here. For example, when using [{ "exists": true }] the generated template preserves the booleans but the CF deployment fails with Reason: exists match pattern must be either true or false...

Apparently this works for now:

source: [ { prefix: "your.prefix.here"} ] as any[]

is there a workaround for {exists: right now?

Was this page helpful?
0 / 5 - 0 ratings