# Match

An event pattern matcher.

Extends: Match
Implements: IResolvable

- Source: [`aws-events/lib/event-pattern.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-events/lib/event-pattern.ts#L20)
- Type last changed: v2.172.0 · 7 Dec 2024

## Example

```ts
const rule = new events.Rule(this, 'rule', {
  eventPattern: {
    detail: {
      object: {
        // Matchers may appear at any level
        size: events.Match.greaterThan(1024),
      },

      // 'OR' condition
      'source-storage-class': events.Match.anyOf(
        events.Match.prefix('GLACIER'),
        events.Match.exactString('DEEP_ARCHIVE'),
      ),
    },

    // If you prefer, you can use a low level array of strings, as directly consumed by EventBridge
    source: ['aws.s3'],

    region: events.Match.anythingButPrefix('us-gov'),
  },
});
```

## Properties

- `creationStack`: string[] — 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.

## Methods

- `allOf(...matchers: any[]): string[]` (static) — Matches an event if any of the provided matchers do.

  Only numeric matchers are accepted.

- `anyOf(...matchers: any[]): string[]` (static) — Matches an event if any of the provided matchers does.

- `anythingBut(...values: any[]): string[]` (static) — Matches anything except what's provided in the rule.

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

- `anythingButEqualsIgnoreCase(...values: string[]): string[]` (static) — Matches any string that doesn't match with the given value regardless of character casing.

- `anythingButPrefix(...values: string[]): string[]` (static) — Matches any string that doesn't start with the given prefix.

- `anythingButSuffix(...values: string[]): string[]` (static) — Matches any string that doesn't end with the given suffix.

- `anythingButWildcard(...values: string[]): string[]` (static) — Matches any string that doesn't match with the given wildcard pattern.

- `asList(): string[]` — A representation of this matcher as a list of strings.

- `cidr(range: string): string[]` (static) — Matches IPv4 and IPv6 network addresses using the Classless Inter-Domain Routing (CIDR) format.

- `doesNotExist(): string[]` (static) — Matches when the field is absent from the JSON of the event.

- `equal(value: number): string[]` (static) — Matches numbers equal to the provided value.

- `equalsIgnoreCase(value: string): string[]` (static) — Matches a string, regardless of case, in the JSON of the event.

- `exactString(value: string): string[]` (static) — Matches a string, exactly, in the JSON of the event.

- `exists(): string[]` (static) — Matches when the field is present in the JSON of the event.

- `greaterThan(value: number): string[]` (static) — Matches numbers greater than the provided value.

- `greaterThanOrEqual(value: number): string[]` (static) — Matches numbers greater than, or equal to, the provided value.

- `interval(lower: number, upper: number): string[]` (static) — Matches numbers inside a closed numeric interval. Equivalent to:.

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

  **Parameters**

  - `lower` — Lower bound (inclusive).
  - `upper` — Upper bound (inclusive).

- `ipAddressRange(range: string): string[]` (static) — Matches IPv4 and IPv6 network addresses using the Classless Inter-Domain Routing (CIDR) format.

  Alias of `cidr()`.

- `lessThan(value: number): string[]` (static) — Matches numbers less than the provided value.

- `lessThanOrEqual(value: number): string[]` (static) — Matches numbers less than, or equal to, the provided value.

- `nullValue(): string[]` (static) — Matches a null value in the JSON of the event.

- `prefix(value: string): string[]` (static) — Matches strings with the given prefix in the JSON of the event.

- `prefixEqualsIgnoreCase(value: string): string[]` (static) — Matches strings with the given prefix in the JSON of the event regardless of the casing.

- `resolve(context: IResolveContext): any` — Produce the Token's value at resolution time.

- `suffix(value: string): string[]` (static) — Matches strings with the given suffix in the JSON of the event.

- `suffixEqualsIgnoreCase(value: string): string[]` (static) — Matches strings with the given suffix in the JSON of the event regardless of the casing.

- `toString(): string` — Return a string representation of this resolvable object.

  Returns a reversible string representation.

- `wildcard(value: string): string[]` (static) — Matches strings with the given wildcard pattern in the JSON of the event.
