class Match
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.Events.Match |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsevents#Match |
Java | software.amazon.awscdk.services.events.Match |
Python | aws_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
Name | Type | Description |
---|---|---|
creation | string[] | 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
Name | Description |
---|---|
as | A representation of this matcher as a list of strings. |
resolve(context) | Produce the Token's value at resolution time. |
to | Return a string representation of this resolvable object. |
static all | Matches an event if any of the provided matchers do. |
static any | Matches an event if any of the provided matchers does. |
static anything | Matches anything except what's provided in the rule. |
static anything | 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 does | Matches when the field is absent from the JSON of the event. |
static equal(value) | Matches numbers equal to the provided value. |
static equals | Matches a string, regardless of case, in the JSON of the event. |
static exact | 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 greater | Matches numbers greater than the provided value. |
static greater | Matches numbers greater than, or equal to, the provided value. |
static interval(lower, upper) | Matches numbers inside a closed numeric interval. Equivalent to:. |
static ip | Matches IPv4 and IPv6 network addresses using the Classless Inter-Domain Routing (CIDR) format. |
static less | Matches numbers less than the provided value. |
static less | Matches numbers less than, or equal to, the provided value. |
static null | 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. |
List()
aspublic asList(): string[]
Returns
string[]
A representation of this matcher as a list of strings.
resolve(context)
public resolve(context: IResolveContext): any
Parameters
- context
IResolve
Context
Returns
any
Produce the Token's value at resolution time.
String()
topublic toString(): string
Returns
string
Return a string representation of this resolvable object.
Returns a reversible string representation.
Of(...matchers)
static allpublic 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.
Of(...matchers)
static anypublic static anyOf(...matchers: any[]): string[]
Parameters
- matchers
any
Returns
string[]
Matches an event if any of the provided matchers does.
But(...values)
static anythingpublic 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.
ButPrefix(prefix)
static anythingpublic 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.
NotExist()
static doespublic 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.
IgnoreCase(value)
static equalspublic static equalsIgnoreCase(value: string): string[]
Parameters
- value
string
Returns
string[]
Matches a string, regardless of case, in the JSON of the event.
String(value)
static exactpublic 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.
Than(value)
static greaterpublic static greaterThan(value: number): string[]
Parameters
- value
number
Returns
string[]
Matches numbers greater than the provided value.
ThanOrEqual(value)
static greaterpublic 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))
AddressRange(range)
static ippublic 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()
.
Than(value)
static lesspublic static lessThan(value: number): string[]
Parameters
- value
number
Returns
string[]
Matches numbers less than the provided value.
ThanOrEqual(value)
static lesspublic static lessThanOrEqual(value: number): string[]
Parameters
- value
number
Returns
string[]
Matches numbers less than, or equal to, the provided value.
Value()
static nullpublic 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.