全部產品
Search
文件中心

:ALIYUN::EventBridge::Rule

更新時間:Jul 19, 2025

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、256和512(共167個512)。

DeadLetterQueue

Map

無效信件佇列。

未處理或超過最大重試次數的事件將寫入無效信件佇列。以下隊列類型支援無效信件佇列功能:Apache RocketMQ的訊息佇列、Message Service(MNS)、Apache Kafka的訊息佇列和EventBridge。更多資訊,請參考DeadLetterQueue屬性

ConcurrentConfig

Map

並發控制配置。

更多資訊。請參考ConcurrentConfig屬性

ErrorsTolerance

String

容錯策略。

取值:

  • ALL:允許容錯。如果發生錯誤,則不會阻止事件處理。如果在達到重試策略指定的最大重試次數後仍無法發送郵件,則會根據您的配置將郵件傳遞到無效信件佇列或將其丟棄。

  • NONE:不允許容錯。如果發生錯誤,並且在達到重試策略指定的最大重試次數後無法發送訊息,則會阻止事件處理。

DeadLetterQueue文法

"DeadLetterQueue": 
  {
    "Arn": String
  }

DeadLetterQueue屬性

屬性名稱

類型

必須

允許更新

描述

約束

Arn

String

無效信件佇列的阿里雲資源名稱(ARN)。

未處理或超過最大重試次數的事件將寫入無效信件佇列。以下隊列類型支援ARN功能:Apache RocketMQ的MNS和訊息佇列。

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"
        ]
      }
    }
  }
}