TestEventPattern
Tests whether the specified event pattern matches the provided event.
Most services in AWS treat : or / as the same character in Amazon Resource Names (ARNs). However, EventBridge uses an exact match in event patterns and rules. Be sure to use the correct ARN characters when creating event patterns so that they match the ARN syntax in the event you want to match.
Request Syntax
{
"Event": "string
",
"EventPattern": "string
"
}
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
The request accepts the following data in JSON format.
- Event
-
The event, in JSON format, to test against the event pattern. The JSON must follow the format specified in AWS Events, and the following fields are mandatory:
-
id
-
account
-
source
-
time
-
region
-
resources
-
detail-type
Type: String
Required: Yes
-
- EventPattern
-
The event pattern. For more information, see Events and Event Patterns in the Amazon EventBridge User Guide .
Type: String
Length Constraints: Maximum length of 4096.
Required: Yes
Response Syntax
{
"Result": boolean
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- Result
-
Indicates whether the event matches the event pattern.
Type: Boolean
Errors
For information about the errors that are common to all actions, see Common Errors.
- InternalException
-
This exception occurs due to unexpected causes.
HTTP Status Code: 500
- InvalidEventPatternException
-
The event pattern is not valid.
HTTP Status Code: 400
Examples
Tests that a given event matches a given event pattern
The following is an example of a TestEventPattern request and response.
Sample Request
POST / HTTP/1.1
Host: events.<region>.<domain>
x-amz-Date: <Date>
Authorization: AWS4-HMAC-SHA256 Credential=<Credential>, SignedHeaders=content-type;date;host;user-agent;x-amz-date;x-amz-target;x-amzn-requestid, Signature=<Signature>
User-Agent: <UserAgentString>
Content-Type: application/x-amz-json-1.1
Content-Length: <PayloadSizeBytes>
Connection: Keep-Alive
X-Amz-Target: AWSEvents.TestEventPattern
{
"EventPattern": "{\"source\": [\"com.mycompany.myapp\"]}",
"Event": "{\"id\": \"e00c66cb-fe7a-4fcc-81ad-58eb60f5d96b\", \"detail-type\": \"myDetailType\", \"source\": \"com.mycompany.myapp\", \"account\": \"123456789012\", \"time\": \"2016-01-10T01:29:23Z\", \"region\": \"us-east-1\", \"resources\": [\"resource1\", \"resource2\"], \"detail\": {\"key1\": \"value1\", \"key2\": \"value2\"}}"
}
}
Sample Response
HTTP/1.1 200 OK
x-amzn-RequestId: <RequestId>
Content-Type: application/x-amz-json-1.1
Content-Length: <PayloadSizeBytes>
Date: <Date>
{
"Result": true
}
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: