An event pattern defines the criteria that EventBridge uses to filter and route events to targets. Only events whose structure and field values match the pattern are forwarded.
How it works
EventBridge compares each incoming event against your event pattern using the following rules:
The event must contain every field specified in the pattern, with the same nested structure.
Matching is character-by-character and case-sensitive. EventBridge does not modify strings during comparison.
All values must be valid JSON: numbers, double-quoted strings, or unquoted keywords (
true,false,null).AND logic applies across fields: the event must satisfy all field conditions in the pattern.
OR logic applies within a field's value array: the event matches if it satisfies any value in the array.
Operator reference
| Operator | Description | Syntax example |
|---|---|---|
| Exact value | Source is acs.oss | "source": ["acs.oss"] |
| Prefix | Source starts with acs. | "source": [{"prefix": "acs."}] |
| Suffix | Subject ends with .jpg | "subject": [{"suffix": ".jpg"}] |
| Contains | Type contains Normal | "type": [{"contains": "Normal"}] |
| Anything-but (string) | State is not initializing | "state": [{"anything-but": "initializing"}] |
| Anything-but (number) | Limit is not 123 | "x-limit": [{"anything-but": 123}] |
| Anything-but (list) | State is not stopped or overloaded | "state": [{"anything-but": ["stopped", "overloaded"]}] |
| Anything-but (prefix) | State does not start with init | "state": [{"anything-but": {"prefix": "init"}}] |
| Numeric | Value equals, or falls within a range | "c-count": [{"numeric": [">", 0, "<=", 5]}] |
| CIDR (IP address) | IP is in 10.0.0.0/24 | "source-ip": [{"cidr": "10.0.0.0/24"}] |
| Exists | Field exists or does not exist | "state": [{"exists": false}] |
| Null | Value is null | "responseElements": [null] |
| Empty string | Value is "" | "eventVersion": [""] |
Event structure
All examples use events based on the CloudEvents v1.0 specification. A typical event looks like this:
{
"id": "7adc8c1a-645d-4476-bdef-5d6fb57f****",
"source": "acs.oss",
"specversion": "1.0",
"type": "oss:ObjectCreated:PostObject",
"datacontenttype": "application/json",
"dataschema": "http://example.com/test.json",
"subject": "acs:oss:cn-hangzhou:1234567:xls-papk/game_apk/123.jpg",
"time": "2020-08-17T16:04:46.149Asia/Shanghai",
"data": {
"name": "test",
"scope": 100
}
}Each section below shows the pattern syntax and describes which events match.
Exact value
Match events where a field equals a specific value. Wrap the value in an array.
Pattern -- match events where source is acs.oss:
{
"source": ["acs.oss"]
}Result: An event with "source": "acs.oss" matches. Events with "source": "acs.aliyuncvc" or "source": "acs.imm" do not match.
Specify multiple values in the array to match any of them (OR logic):
{
"subject": [
"acs:oss:cn-hangzhou:1234567:xls-papk/game_apk/123.jpg",
"acs:oss:cn-hangzhou:1112223:xls-papk/game_apk/123.jpg",
"acs:oss:cn-hangzhou:4455667:xls-papk/game_apk/123.jpg"
]
}If the field value in the event is also an array, the event matches when the two arrays share at least one common element.
Prefix
Match events where a field value starts with a given string.
Pattern -- match events where source starts with acs.:
{
"source": [{"prefix": "acs."}]
}Result: Events with "source": "acs.oss" and "source": "acs.imm" both match.
Suffix
Match events where a field value ends with a given string. Prefix and suffix operators can be combined within the same field.
Pattern -- match events where subject starts with acs:oss:cn-hangzhou:1234567:xls-papk/ and ends with .jpg or .txt:
{
"subject": [
{"prefix": "acs:oss:cn-hangzhou:1234567:xls-papk/"},
{"suffix": ".txt"},
{"suffix": ".jpg"}
]
}Result: An event with "subject": "acs:oss:cn-hangzhou:1234567:xls-papk/game_apk/123.jpg" matches (satisfies both the prefix and the .jpg suffix). An event with "subject": "acs:oss:cn-hangzhou:1234567:xls-papk/game_apk/123.png" also matches because OR logic applies across the array -- it satisfies the prefix condition even though it does not match .txt or .jpg.
Contains
Match events where a field value contains a given substring.
Single substring
Pattern -- match events where type contains Normal:
{
"type": [{"contains": "Normal"}]
}Result: An event with "type": "UserNormalEvent" matches. An event with "type": "UserErrorEvent" does not match.
Multiple substrings (OR logic)
Pattern -- match events where type contains Normal or Error:
{
"type": [
{"contains": "Normal"},
{"contains": "Error"}
]
}Result: Events with "type": "UserNormalEvent" and "type": "UserErrorEvent" both match. An event with "type": "UserOtherEvent" does not match.
Anything-but (exclusion)
Match events where a field value does not equal one or more specified values. The anything-but operator supports strings, numbers, lists, and prefix-based exclusion.
Exclude a single string
Pattern -- match events where data.state is not initializing:
{
"data": {
"state": [{"anything-but": "initializing"}]
}
}Exclude a single number
Pattern -- match events where data.x-limit is not 123:
{
"data": {
"x-limit": [{"anything-but": 123}]
}
}Combine both conditions. Both must be satisfied (AND logic across fields):
{
"data": {
"state": [{"anything-but": "initializing"}],
"x-limit": [{"anything-but": 123}]
}
}Result: An event with "state": "running" and "x-limit": 456 matches. An event missing the state field does not match because the event must contain all fields specified in the pattern.
Exclude multiple strings
Pattern -- match events where data.state is not stopped or overloaded:
{
"data": {
"state": [{"anything-but": ["stopped", "overloaded"]}]
}
}Result: An event with "state": "terminated" matches. An event with "state": "stopped" does not match.
Exclude multiple numbers
Pattern -- match events where data.x-limit is not 100, 200, or 300:
{
"data": {
"x-limit": [{"anything-but": [100, 200, 300]}]
}
}Result: An event with "x-limit": 456 matches. An event with "x-limit": 200 does not match.
Exclude by prefix
Pattern -- match events where data.state does not start with init:
{
"data": {
"state": [{"anything-but": {"prefix": "init"}}]
}
}Result: An event with "state": "pending" matches. An event with "state": "initializing" does not match.
Exclude a specific source
Pattern -- match events not from Cloud Video Conferencing (acs.aliyuncvc):
{
"source": [{"anything-but": ["acs.aliyuncvc"]}]
}Result: An event with "source": "acs.oss" matches. An event with "source": "acs.aliyuncvc" does not match.
Exclude by source prefix
Pattern -- match events from custom applications (exclude all Alibaba Cloud service events):
{
"source": [{"anything-but": {"prefix": "acs."}}]
}Result: An event with "source": "my-app" matches. An event with "source": "acs.oss" does not match.
Numeric value and range
Match events where a numeric field equals a value or falls within a range. Supported comparison operators: >, <, <=, =.
Pattern -- match events where c-count is between 0 (exclusive) and 5 (inclusive), d-count is less than 10, and x-limit equals 301.8:
{
"data": {
"c-count": [{"numeric": [">", 0, "<=", 5]}],
"d-count": [{"numeric": ["<", 10]}],
"x-limit": [{"numeric": ["=", 301.8]}]
}
}Result: An event with "c-count": 5, "d-count": 7, and "x-limit": 301.8 matches. An event with "x-limit": 300 does not match.
Numeric matching only supports JSON-format values between -1.0e9 and +1.0e9, with a precision of 15 digits and 6 decimal places.
IP address (CIDR)
Match events where a field in the data object contains an IP address within a specified CIDR range.
Pattern -- match events where data.source-ip is in the 10.0.0.0/24 subnet:
{
"data": {
"source-ip": [{"cidr": "10.0.0.0/24"}]
}
}Result: An event with "source-ip": "10.0.0.123" matches. An event with "source-ip": "192.168.0.123" does not match.
Only IPv4 addresses are supported.
Null and empty string
Empty string
Match events where a field value is an empty string ("").
Pattern -- match events where data.eventVersion is empty:
{
"data": {
"eventVersion": [""]
}
}Null
Match events where a field value is null.
Pattern -- match events where data.responseElements is null:
{
"data": {
"responseElements": [null]
}
}A null value and an empty string ("") are distinct. A pattern that matches empty strings does not match null values, and vice versa.
Field existence
Match events based on whether a field exists in the data object.
Pattern -- match events where the data.state field does not exist:
{
"data": {
"state": [{"exists": false}]
}
}To match events where a field does exist, set exists to true:
{
"data": {
"state": [{"exists": true}]
}
}Combined conditions
Combine multiple operators across different fields for precise filtering. All conditions must be satisfied (AND logic).
Pattern -- match events that satisfy all of the following conditions:
sourcestarts withacs.data.stateis notinitializingdata.source-ipis in10.0.0.0/24data.c-countis between 0 (exclusive) and 5 (inclusive)data.d-countis less than 10data.x-limitis not100,200, or300
{
"source": [{"prefix": "acs."}],
"data": {
"state": [{"anything-but": "initializing"}],
"source-ip": [{"cidr": "10.0.0.0/24"}],
"c-count": [{"numeric": [">", 0, "<=", 5]}],
"d-count": [{"numeric": ["<", 10]}],
"x-limit": [{"anything-but": [100, 200, 300]}]
}
}Result: An event with "source": "acs.oss", "state": "pending", "source-ip": "10.0.0.123", "c-count": 5, "d-count": 7, and "x-limit": 301.8 matches. Changing any single value to violate its condition (for example, "state": "initializing" or "source-ip": "192.168.0.123") causes the event to fail.
Limitations
| Constraint | Detail |
|---|---|
| Numeric precision | Values must be between -1.0e9 and +1.0e9, accurate to 15 digits and 6 decimal places |
| IP version | Only IPv4 addresses are supported for CIDR matching |
| Null vs. empty string | null and "" are distinct; a pattern for one does not match the other |
| Field presence | The event must contain all fields specified in the pattern |
| Case sensitivity | All string matching is case-sensitive |