aws-cdk-lib.aws_events.Match

class Match

LanguageType name
.NETAmazon.CDK.AWS.Events.Match
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsevents#Match
Javasoftware.amazon.awscdk.services.events.Match
Pythonaws_cdk.aws_events.Match
TypeScript (source)aws-cdk-lib » aws_events » Match

Implements IResolvable

An event pattern matcher.

Example

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'),
      ),
    },
    detailType: events.Match.equalsIgnoreCase('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.anythingButPrefix('us-gov'),
  },
});

Properties

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

creationStack

Type: 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

NameDescription
asList()A representation of this matcher as a list of strings.
resolve(context)Produce the Token's value at resolution time.
toString()Return a string representation of this resolvable object.
static allOf(...matchers)Matches an event if any of the provided matchers do.
static anyOf(...matchers)Matches an event if any of the provided matchers does.
static anythingBut(...values)Matches anything except what's provided in the rule.
static anythingButPrefix(prefix)Matches any string that doesn't start with the given prefix.
static cidr(range)Matches IPv4 and IPv6 network addresses using the Classless Inter-Domain Routing (CIDR) format.
static doesNotExist()Matches when the field is absent from the JSON of the event.
static equal(value)Matches numbers equal to the provided value.
static equalsIgnoreCase(value)Matches a string, regardless of case, in the JSON of the event.
static exactString(value)Matches a string, exactly, in the JSON of the event.
static exists()Matches when the field is present in the JSON of the event.
static greaterThan(value)Matches numbers greater than the provided value.
static greaterThanOrEqual(value)Matches numbers greater than, or equal to, the provided value.
static interval(lower, upper)Matches numbers inside a closed numeric interval. Equivalent to:.
static ipAddressRange(range)Matches IPv4 and IPv6 network addresses using the Classless Inter-Domain Routing (CIDR) format.
static lessThan(value)Matches numbers less than the provided value.
static lessThanOrEqual(value)Matches numbers less than, or equal to, the provided value.
static nullValue()Matches a null value in the JSON of the event.
static prefix(value)Matches strings with the given prefix in the JSON of the event.
static suffix(value)Matches strings with the given suffix in the JSON of the event.

asList()

public asList(): string[]

Returns

  • string[]

A representation of this matcher as a list of strings.


resolve(context)

public resolve(context: IResolveContext): any

Parameters

  • context IResolveContext

Returns

  • any

Produce the Token's value at resolution time.


toString()

public toString(): string

Returns

  • string

Return a string representation of this resolvable object.

Returns a reversible string representation.


static allOf(...matchers)

public static allOf(...matchers: any[]): string[]

Parameters

  • matchers any

Returns

  • string[]

Matches an event if any of the provided matchers do.

Only numeric matchers are accepted.


static anyOf(...matchers)

public static anyOf(...matchers: any[]): string[]

Parameters

  • matchers any

Returns

  • string[]

Matches an event if any of the provided matchers does.


static anythingBut(...values)

public static anythingBut(...values: any[]): string[]

Parameters

  • values any

Returns

  • string[]

Matches anything except what's provided in the rule.

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


static anythingButPrefix(prefix)

public static anythingButPrefix(prefix: string): string[]

Parameters

  • prefix string

Returns

  • string[]

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


static cidr(range)

public static cidr(range: string): string[]

Parameters

  • range string

Returns

  • string[]

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


static doesNotExist()

public static doesNotExist(): string[]

Returns

  • string[]

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


static equal(value)

public static equal(value: number): string[]

Parameters

  • value number

Returns

  • string[]

Matches numbers equal to the provided value.


static equalsIgnoreCase(value)

public static equalsIgnoreCase(value: string): string[]

Parameters

  • value string

Returns

  • string[]

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


static exactString(value)

public static exactString(value: string): string[]

Parameters

  • value string

Returns

  • string[]

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


static exists()

public static exists(): string[]

Returns

  • string[]

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


static greaterThan(value)

public static greaterThan(value: number): string[]

Parameters

  • value number

Returns

  • string[]

Matches numbers greater than the provided value.


static greaterThanOrEqual(value)

public static greaterThanOrEqual(value: number): string[]

Parameters

  • value number

Returns

  • string[]

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


static interval(lower, upper)

public static interval(lower: number, upper: number): string[]

Parameters

  • lower number — Lower bound (inclusive).
  • upper number — Upper bound (inclusive).

Returns

  • string[]

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

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


static ipAddressRange(range)

public static ipAddressRange(range: string): string[]

Parameters

  • range string

Returns

  • string[]

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

Alias of cidr().


static lessThan(value)

public static lessThan(value: number): string[]

Parameters

  • value number

Returns

  • string[]

Matches numbers less than the provided value.


static lessThanOrEqual(value)

public static lessThanOrEqual(value: number): string[]

Parameters

  • value number

Returns

  • string[]

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


static nullValue()

public static nullValue(): string[]

Returns

  • string[]

Matches a null value in the JSON of the event.


static prefix(value)

public static prefix(value: string): string[]

Parameters

  • value string

Returns

  • string[]

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


static suffix(value)

public static suffix(value: string): string[]

Parameters

  • value string

Returns

  • string[]

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