Creates an event rule.
Operation description
You can call this API operation to create an event rule.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
eventbridge:CreateRule | create | *Rule acs:eventbridge:{#regionId}:{#accountId}:eventbus/{#EventBusName}/rule/{#RuleName} |
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
EventBusName | string | Yes | The name of the event bus. | MyEventBus |
Description | string | No | The description of the event bus. | |
RuleName | string | Yes | The name of the event rule. | MNSRule |
Status | string | No | The status of the event rule. Valid values: ENABLE: enables the event rule. It is the default status of the event rule. DISABLE: disables the event rule. | ENABLE |
FilterPattern | string | Yes | The event pattern, in JSON format. Valid values: stringEqual and stringExpression. You can specify up to five expressions in the map data structure in each field. You can specify up to five expressions in the map data structure in each field. | {\"source\": [{\"prefix\": \"acs.\"}],\"type\": [{\"prefix\":\"oss:ObjectReplication\"}],\"subject\":[{\"prefix\":\"acs:oss:cn-hangzhou:123456789098****:my-movie-bucket/\", \"suffix\":\".txt\"}]} |
EventTargets | array<object> | Yes | The event targets. | |
object | Yes | |||
Id | string | Yes | The ID of the custom event target. | 12021 |
Type | string | Yes | The type of the event target. For more information, see Event target parameters. | acs.mns.queue |
Endpoint | string | No | The endpoint of the event target. | acs:mns:cn-hangzhou:123456789098****:queues/myqueue |
PushRetryStrategy | string | No | The retry policy that is used to push events. Valid values: BACKOFF_RETRY: backoff retry. If an event failed to be pushed, it can be retried up to three times. The interval between two consecutive retries is a random value between 10 and 20 seconds. EXPONENTIAL_DECAY_RETRY: exponential decay retry. If an event failed to be pushed, it can be retried up to 176 times. The interval between two consecutive retries exponentially increases to 512 seconds, and the total retry time is one day. The specific retry intervals are 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 512, ..., and 512 seconds. The interval of 512 seconds is used for 167 retries. | BACKOFF_RETRY |
DeadLetterQueue | object | No | The dead-letter queue. Events that are not processed or whose maximum retries are exceeded are written to the dead-letter queue. The dead-letter queue feature is supported by the following queue types: Message Queue for Apache RocketMQ, Message Service (MNS), Message Queue for Apache Kafka, and EventBridge. | |
Arn | string | No | The Alibaba Cloud Resource Name (ARN) of the dead-letter queue. Events that are not processed or whose maximum retries are exceeded are written to the dead-letter queue. The ARN feature is supported by the following queue types: MNS and Message Queue for Apache RocketMQ. | acs:mns:cn-hangzhou:123456789098****:/queues/rule-deadletterqueue |
ErrorsTolerance | string | No | The fault tolerance policy. Valid values: ALL: allows fault tolerance. If an error occurs, the event processing is not blocked. If the message fails to be sent after the maximum number of retries specified by the retry policy is reached, the message is delivered to the dead-letter queue or discarded based on your configurations. NONE: does not allow fault tolerance. If an error occurs and the message fails to be sent after the maximum number of retries specified by the retry policy is reached, the event processing is blocked. | ALL |
ParamList | array<object> | No | The parameters that are configured for the event target. | |
object | No | |||
ResourceKey | string | No | The resource parameter of the event target. For more information, see Limits | body |
Form | string | No | The format that is used by the event target parameter. For more information, see Limits. | TEMPLATE |
Value | string | No | The value of the event target parameter. | {\"key\"=\"value\"} |
Template | string | No | The template that is used by the event target parameter. | The value of ${key} is ${value}! |
Sample requests
POST /openapi/createRule HTTP/1.1 Host: 123456789098****.eventbridge.cn-hangzhou.aliyuncs.com Date: Sat, 18 Apr 2020 05:30:41 GMT x-eventbridge-version: 2020-04-01 Authorization: acs vZ3VL0SuJdHi****:Jo2PbT******azYAYoYslKLvWzg= Content-Type: application/json;charset=UTF-8 Content-Length: 26
{ "EventBusName":"default", "RuleName":"MNSRule", "Description":"Filtering rule for MNS", "Status":"ENABLE", "filterPattern":"{"source": [{"prefix": "acs."}],"type": [{"prefix":"oss:ObjectReplication"}],"subject":[{"prefix":"acs:oss:cn-hangzhou:123456789098****:my-movie-bucket/", "suffix":".txt"}]}", "Targets":[ { "Id":"1", "Type":"acs.mns.queue", "Endpoint":"acs:mns:cn-hangzhou:123456789098****:queues/myqueue", "PushRetryStrategy":"BACKOFF_RETRY", "DeadLetterQueue":{ "Arn":"acs:mns:cn-hangzhou:123456789098****:/queues/rule-deadletterqueue" }, "ParamList":[ { "resourceKey":"queue", "form":"CONSTANT", "value":"myqueue" }, { "resourceKey":"body", "form":"TEMPLATE", "value":"{"key"="value"}", "template":"The value of ${key} is ${value}!" } ] } ] }
Response parameters
Examples
Sample success responses
JSON
format
{
"Message": "Remote error. requestId: [xxxx], error code: [xxx], message: [The target in event rule is invalid! Endpoint is xxx",
"RequestId": "1AD6D598-7506-5D2C-81EA-30E3241A903A",
"Data": {
"RuleARN": "acs:eventbridge:cn-hangzhou:123456789098****:eventbus/default/rule/MNSRule"
},
"Code": "200",
"Success": true
}
Error codes
HTTP status code | Error code | Error message |
---|---|---|
403 | ServiceNotEnable | Service not enable |
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2024-09-25 | The Error code has changed | View Change Details |