

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# EventBridgeRule
<a name="sam-property-statemachine-statemachineeventbridgerule"></a>

描述`EventBridgeRule`事件來源類型的物件，這會將您的狀態機器設定為 Amazon EventBridge 規則的目標。如需詳細資訊，請參閱《Amazon EventBridge 使用者指南》中的[什麼是 Amazon EventBridge？](https://docs.aws.amazon.com/eventbridge/latest/userguide/what-is-amazon-eventbridge.html)。

AWS SAM 會在設定此事件類型時產生 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html) 資源。

## 語法
<a name="sam-property-statemachine-statemachineeventbridgerule-syntax"></a>

若要在 AWS Serverless Application Model (AWS SAM) 範本中宣告此實體，請使用下列語法。

### YAML
<a name="sam-property-statemachine-statemachineeventbridgerule-syntax.yaml"></a>

```
  DeadLetterConfig: {{DeadLetterConfig}}
  EventBusName: {{String}}
  Input: {{String}}
  InputPath: {{String}}
  InputTransformer: {{[InputTransformer](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-inputtransformer.html)}}
  Pattern: {{[EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)}}
  RetryPolicy: {{[RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy)}}
  RuleName: {{String}}
  State: {{String}}
  Target: {{Target}}
```

## Properties
<a name="sam-property-statemachine-statemachineeventbridgerule-properties"></a>

 `DeadLetterConfig`   <a name="sam-statemachine-statemachineeventbridgerule-deadletterconfig"></a>
設定在目標呼叫失敗後 EventBridge 傳送事件的 Amazon Simple Queue Service (Amazon SQS) 佇列。例如，將事件傳送至不存在的 Lambda 函數時，或 EventBridge 沒有足夠的許可來叫用 Lambda 函數時，叫用可能會失敗。如需詳細資訊，請參閱《*Amazon EventBridge 使用者指南*》中的[事件重試政策和使用無效字母佇列](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html)。  
*類型*：[DeadLetterConfig](sam-property-statemachine-statemachinedeadletterconfig.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::Events::Rule``Target`資料類型的 `[DeadLetterConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-deadletterconfig)` 屬性。此屬性的 AWS SAM 版本包含其他子屬性，以防您想要為您 AWS SAM 建立無效字母佇列。

 `EventBusName`   <a name="sam-statemachine-statemachineeventbridgerule-eventbusname"></a>
與此規則相關聯的事件匯流排。如果您省略此屬性， AWS SAM 會使用預設事件匯流排。  
*類型：*字串  
*必要*：否  
*預設*：預設事件匯流排  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[EventBusName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventbusname)` 屬性。

 `Input`   <a name="sam-statemachine-statemachineeventbridgerule-input"></a>
傳遞到目標的有效 JSON 文字。如果您使用此屬性，事件文字本身不會有任何內容傳遞到目標。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule Target` 資源的 `[Input](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-input)` 屬性。

 `InputPath`   <a name="sam-statemachine-statemachineeventbridgerule-inputpath"></a>
當您不想將整個相符事件傳遞至目標時，請使用 `InputPath` 屬性來描述要傳遞的事件部分。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule Target` 資源的 `[InputPath](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-inputpath)` 屬性。

`InputTransformer`  <a name="sam-statemachine-statemachineeventbridgerule-inputtransformer"></a>
此設定能讓您以特定事件資料為基礎，向目標提供自訂輸入。您可從事件擷取一或多組鍵/值對，然後使用該資料將自訂輸入傳送至目標。如需詳細資訊，請參閱[《Amazon EventBridge 使用者指南》中的 Amazon EventBridge 輸入轉換](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-transform-target-input.html)。 * EventBridge *  
*類型*：[InputTransformer](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-inputtransformer)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule``Target`資料類型的 `[InputTransformer](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-inputtransformer.html) ` 屬性。

 `Pattern`   <a name="sam-statemachine-statemachineeventbridgerule-pattern"></a>
說明哪些事件會路由到指定目標。如需詳細資訊，請參閱《Amazon [ EventBridge 使用者指南》中的 EventBridge 中的事件和事件模式](https://docs.aws.amazon.com/eventbridge/latest/userguide/eventbridge-and-event-patterns.html)。 * EventBridge *  
*類型*：[EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)` 屬性。

 `RetryPolicy`   <a name="sam-statemachine-statemachineeventbridgerule-retrypolicy"></a>
包含重試政策設定相關資訊的 `RetryPolicy` 物件。如需詳細資訊，請參閱《*Amazon EventBridge 使用者指南*》中的[事件重試政策和使用無效字母佇列](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html)。  
*類型*：[RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` `Target` 資料類型的 `[RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy)` 屬性。

 `RuleName`   <a name="sam-statemachine-statemachineeventbridgerule-rulename"></a>
 規則的名稱。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-name)` 屬性。

`State`  <a name="sam-statemachine-statemachineeventbridgerule-state"></a>
規則的狀態。  
*有效值*：`[ DISABLED | ENABLED ]`  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[State](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-state)` 屬性。

 `Target`   <a name="sam-statemachine-statemachineeventbridgerule-target"></a>
EventBridge 在觸發規則時叫用 AWS 的資源。您可以使用此屬性來指定目標的邏輯 ID。如果未指定此屬性，則 AWS SAM 會產生目標的邏輯 ID。  
*類型*：[Target](sam-property-statemachine-statemachinetarget.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::Events::Rule` 資源的 `[Targets](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-targets)` 屬性。此屬性的 AWS SAM 版本只允許您指定單一目標的邏輯 ID。

## 範例
<a name="sam-property-statemachine-statemachineeventbridgerule--examples"></a>

### EventBridgeRule
<a name="sam-property-statemachine-statemachineeventbridgerule--examples--eventbridgerule"></a>

以下是`EventBridgeRule`事件來源類型的範例。

#### YAML
<a name="sam-property-statemachine-statemachineeventbridgerule--examples--eventbridgerule--yaml"></a>

```
EBRule:
  Type: EventBridgeRule
  Properties:
    Input: '{"Key": "Value"}'
    Pattern:
      detail:
        state:
          - terminated
```