ALIYUN::EventBridge::Rule

ALIYUN::EventBridge::Rule类型用于在指定的事件总线下创建一个事件规则。

语法

{
  "Type": "ALIYUN::EventBridge::Rule",
  "Properties": {
    "Status": String,
    "EventBusName": String,
    "FilterPattern": Map,
    "Description": String,
    "Targets": List,
    "RuleName": String
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

EventBusName

String

事件总线的名称。

更多信息,请参见使用限制

FilterPattern

Map

事件模式。

JSON格式。取值:

  • stringEqual模式。

  • stringExpression模式 。

说明

最多可容纳5个事件模式。

Targets

List

事件的投递目标。

更多信息,请参见Targets属性

RuleName

String

事件规则的名称。

更多信息,请参见使用限制

Status

String

规则的状态。

取值:

  • ENABLE(默认值):规则已启用。

  • DISABLE:规则已禁用。

Description

String

规则说明。

Targets语法

"Targets": [
  {
    "PushRetryStrategy": String,
    "Type": String,
    "Endpoint": String,
    "Id": String,
    "ParamList": List,
    "DeadLetterQueue": Map,
    "ConcurrentConfig": Map,
    "ErrorsTolerance": String
  }
]

Targets属性

属性名称

类型

必须

允许更新

描述

约束

Endpoint

String

投递端点链接。

Id

String

自定义TargetId。

ParamList

List

事件传递的参数。

更多信息,请参见ParamList属性

Type

String

目标Target类型。

PushRetryStrategy

String

推送重试策略。

取值:

  • BACKOFF_RETRY:退避重试策略。重试3次,每次重试的间隔时间是10秒到20秒之间的随机值。

  • EXPONENTIAL_DECAY_RETRY:指数衰减重试。重试176次,每次重试的间隔时间指数递增至512秒,总计重试时间为1天。

    每次重试的具体间隔时间为(秒):1、2、4、8、16、32、64、128、256512(共167512)。

DeadLetterQueue

Map

死信队列。

未处理或超过最大重试次数的事件将写入死信队列。以下队列类型支持死信队列功能:Apache RocketMQ的消息队列、消息服务(MNS)、Apache Kafka的消息队列和EventBridge。更多信息,请参考DeadLetterQueue属性

ConcurrentConfig

Map

并发控制配置。

更多信息。请参考ConcurrentConfig属性

ErrorsTolerance

String

容错策略。

取值:

  • ALL:允许容错。如果发生错误,则不会阻止事件处理。如果在达到重试策略指定的最大重试次数后仍无法发送邮件,则会根据您的配置将邮件传递到死信队列或将其丢弃。

  • NONE:不允许容错。如果发生错误,并且在达到重试策略指定的最大重试次数后无法发送消息,则会阻止事件处理。

DeadLetterQueue语法

"DeadLetterQueue": 
  {
    "Arn": String
  }

DeadLetterQueue属性

属性名称

类型

必须

允许更新

描述

约束

Arn

String

死信队列的阿里云资源名称(ARN)。

未处理或超过最大重试次数的事件将写入死信队列。以下队列类型支持ARN功能:Apache RocketMQMNS和消息队列。

ConcurrentConfig语法

"ConcurrentConfig": 
  {
    "Concurrency": Integer
  }

ConcurrentConfig属性

属性名称

类型

必须

允许更新

描述

约束

Concurrency

Integer

并发连接数。

ParamList语法

"ParamList": [
  {
    "Form": String,
    "Value": String,
    "ResourceKey": String,
    "Template": String
  }
]

ParamList属性

属性名称

类型

必须

允许更新

描述

约束

Form

String

事件转换的格式。

更多信息,请参见事件目标参数

ResourceKey

String

事件转换的资源参数。

更多信息,请参见事件目标参数

Value

String

事件转换的值。

Template

String

模板样式。

返回值

Fn::GetAtt

  • EventBusName:事件总线的名称。

  • RuleARN:事件规则的ARN,用于授权。

  • RuleName:事件规则的名称。

示例

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  EventBusName:
    Type: String
    Description: The name of the event bus.
  Targets:
    Type: Json
    Description: The event target to which events are delivered.
    MinLength: 1
    MaxLength: 5
  RuleName:
    Type: String
    Description: The name of the event rule.
  FilterPattern:
    Required: true
    Type: Json
    Description:
      en: The event pattern, in the JSON format.
    Label:
      zh-cn: 事件模式
      en: FilterPattern
Resources:
  Rule:
    Type: ALIYUN::EventBridge::Rule
    Properties:
      FilterPattern:
        Ref: FilterPattern
      EventBusName:
        Ref: EventBusName
      Targets:
        Ref: Targets
      RuleName:
        Ref: RuleName
Outputs:
  EventBusName:
    Description: The name of the event bus.
    Value:
      Fn::GetAtt:
        - Rule
        - EventBusName
  RuleARN:
    Description: The Alibaba Cloud Resource Name (ARN) of the event rule. The ARN is used for authorization.
    Value:
      Fn::GetAtt:
        - Rule
        - RuleARN
  RuleName:
    Description: The name of the event rule.
    Value:
      Fn::GetAtt:
        - Rule
        - RuleName
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "EventBusName": {
      "Type": "String",
      "Description": "The name of the event bus."
    },
    "Targets": {
      "Type": "Json",
      "Description": "The event target to which events are delivered.",
      "MinLength": 1,
      "MaxLength": 5
    },
    "RuleName": {
      "Type": "String",
      "Description": "The name of the event rule."
    },
    "FilterPattern": {
      "Required": true,
      "Type": "Json",
      "Description": {
        "en": "The event pattern, in the JSON format."
      },
      "Label": {
        "zh-cn": "事件模式",
        "en": "FilterPattern"
      }
    }
  },
  "Resources": {
    "Rule": {
      "Type": "ALIYUN::EventBridge::Rule",
      "Properties": {
        "FilterPattern": {
          "Ref": "FilterPattern"
        },
        "EventBusName": {
          "Ref": "EventBusName"
        },
        "Targets": {
          "Ref": "Targets"
        },
        "RuleName": {
          "Ref": "RuleName"
        }
      }
    }
  },
  "Outputs": {
    "EventBusName": {
      "Description": "The name of the event bus.",
      "Value": {
        "Fn::GetAtt": [
          "Rule",
          "EventBusName"
        ]
      }
    },
    "RuleARN": {
      "Description": "The Alibaba Cloud Resource Name (ARN) of the event rule. The ARN is used for authorization.",
      "Value": {
        "Fn::GetAtt": [
          "Rule",
          "RuleARN"
        ]
      }
    },
    "RuleName": {
      "Description": "The name of the event rule.",
      "Value": {
        "Fn::GetAtt": [
          "Rule",
          "RuleName"
        ]
      }
    }
  }
}