Match

class aws_cdk.aws_events.Match(*args: Any, **kwargs)

Bases: object

An event pattern matcher.

ExampleMetadata:

infused

Example:

rule = events.Rule(self, "rule",
    event_pattern=events.EventPattern(
        detail={
            "object": {
                # Matchers may appear at any level
                "size": events.Match.greater_than(1024)
            },

            # 'OR' condition
            "source-storage-class": events.Match.any_of(
                events.Match.prefix("GLACIER"),
                events.Match.exact_string("DEEP_ARCHIVE"))
        },
        detail_type=events.Match.equals_ignore_case("object created"),

        # If you prefer, you can use a low level array of strings, as directly consumed by EventBridge
        source=["aws.s3"],

        region=events.Match.anything_but_prefix("us-gov")
    )
)

Methods

as_list()

A representation of this matcher as a list of strings.

Return type:

List[str]

resolve(context)

Produce the Token’s value at resolution time.

Parameters:

context (IResolveContext) –

Return type:

Any

to_string()

Return a string representation of this resolvable object.

Returns a reversible string representation.

Return type:

str

Attributes

creation_stack

The creation stack of this resolvable which will be appended to errors thrown during resolution.

This may return an array with a single informational element indicating how to get this property populated, if it was skipped for performance reasons.

Static Methods

classmethod all_of(*matchers)

Matches an event if any of the provided matchers do.

Only numeric matchers are accepted.

Parameters:

matchers (Any) –

Return type:

List[str]

classmethod any_of(*matchers)

Matches an event if any of the provided matchers does.

Parameters:

matchers (Any) –

Return type:

List[str]

classmethod anything_but(*values)

Matches anything except what’s provided in the rule.

The list of provided values must contain only strings or only numbers.

Parameters:

values (Any) –

Return type:

List[str]

classmethod anything_but_prefix(prefix)

Matches any string that doesn’t start with the given prefix.

Parameters:

prefix (str) –

Return type:

List[str]

classmethod cidr(range)

Matches IPv4 and IPv6 network addresses using the Classless Inter-Domain Routing (CIDR) format.

Parameters:

range (str) –

Return type:

List[str]

classmethod does_not_exist()

Matches when the field is absent from the JSON of the event.

Return type:

List[str]

classmethod equal(value)

Matches numbers equal to the provided value.

Parameters:

value (Union[int, float]) –

Return type:

List[str]

classmethod equals_ignore_case(value)

Matches a string, regardless of case, in the JSON of the event.

Parameters:

value (str) –

Return type:

List[str]

classmethod exact_string(value)

Matches a string, exactly, in the JSON of the event.

Parameters:

value (str) –

Return type:

List[str]

classmethod exists()

Matches when the field is present in the JSON of the event.

Return type:

List[str]

classmethod greater_than(value)

Matches numbers greater than the provided value.

Parameters:

value (Union[int, float]) –

Return type:

List[str]

classmethod greater_than_or_equal(value)

Matches numbers greater than, or equal to, the provided value.

Parameters:

value (Union[int, float]) –

Return type:

List[str]

classmethod interval(lower, upper)

Matches numbers inside a closed numeric interval. Equivalent to:.

Match.allOf(Match.greaterThanOrEqual(lower), Match.lessThanOrEqual(upper))

Parameters:
  • lower (Union[int, float]) – Lower bound (inclusive).

  • upper (Union[int, float]) – Upper bound (inclusive).

Return type:

List[str]

classmethod ip_address_range(range)

Matches IPv4 and IPv6 network addresses using the Classless Inter-Domain Routing (CIDR) format.

Alias of cidr().

Parameters:

range (str) –

Return type:

List[str]

classmethod less_than(value)

Matches numbers less than the provided value.

Parameters:

value (Union[int, float]) –

Return type:

List[str]

classmethod less_than_or_equal(value)

Matches numbers less than, or equal to, the provided value.

Parameters:

value (Union[int, float]) –

Return type:

List[str]

classmethod null_value()

Matches a null value in the JSON of the event.

Return type:

List[str]

classmethod prefix(value)

Matches strings with the given prefix in the JSON of the event.

Parameters:

value (str) –

Return type:

List[str]

classmethod suffix(value)

Matches strings with the given suffix in the JSON of the event.

Parameters:

value (str) –

Return type:

List[str]