

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

# 在 AWS CloudFormation 堆疊中包含 Amazon EventBridge 資源
<a name="related-services-cfn"></a>

CloudFormation 可讓您透過將基礎設施視為程式碼，以集中且可重複的方式設定和管理跨帳戶和區域的 AWS 資源。CloudFormation 透過讓您建立*範本* (定義您要佈建和管理的資源) 來執行此作業。這些資源可能包括 EventBridge 成品，例如事件匯流排和規則、管道、結構描述和排程等。使用這些資源，以便將 EventBridge 功能包含在您透過 CloudFormation 佈建和管理的技術堆疊中。

## 中的可用 Amazon EventBridge 資源 AWS CloudFormation
<a name="related-services-cfn-resources"></a>

EventBridge 在下列資源命名空間中提供可用於 CloudFormation 範本的資源：
+ [AWS::Events](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_Events.html)

  範本範例包括：
  + [為 PagerDuty 建立 API 目的地](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-apidestination.html#aws-resource-events-apidestination--examples)
  + [為 Slack 建立 API 目的地](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-apidestination.html#aws-resource-events-apidestination--examples)
  + [使用 ApiKey 授權參數建立連線](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-connection.html#aws-resource-events-connection--examples)
  + [使用 OAuth 授權參數建立連線](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-connection.html#aws-resource-events-connection--examples)
  + [使用事件複寫建立全域端點](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-endpoint.html#aws-resource-events-endpoint--examples)
  + [使用多個主體和動作的拒絕政策](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-eventbuspolicy.html#aws-resource-events-eventbuspolicy--examples)
  + [使用自訂事件匯流排將許可授予組織](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-eventbuspolicy.html#aws-resource-events-eventbuspolicy--examples)
  + [建立跨區域規則](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#aws-resource-events-rule--examples)
  + [為目標建立內含無效字母佇列的規則](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#aws-resource-events-rule--examples)
  + [定期調用 Lambda 函數](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#aws-resource-events-rule--examples)
  + [調用 Lambda 函數以回應事件](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#aws-resource-events-rule--examples)
  + [通知主題以回應日誌項目](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#aws-resource-events-rule--examples)
+ [AWS::EventSchemas](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_EventSchemas.html)
+ [AWS::Pipes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_Pipes.html)

  範本範例包括：
  + [使用事件篩選條件建立管道](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-pipes-pipe.html#aws-resource-pipes-pipe--examples)
+ [AWS::Scheduler](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_Scheduler.html)

## 產生 AWS CloudFormation 範本的 Amazon EventBridge 資源定義
<a name="related-services-cfn-generate-resources"></a>

EventBridge 主控台可讓您從帳戶中的現有事件匯流排、規則和管道建立 CloudFormation 範本，協助您快速開始開發 CloudFormation 範本。
+ [從現有的 EventBridge 事件匯流排產生 CloudFormation 範本](eb-generate-event-bus-template.md)
+ [從現有的 EventBridge 規則產生 AWS CloudFormation 範本](rule-generate-template.md)
+ [從 EventBridge 管道產生 CloudFormation 範本](pipes-generate-template.md)

## 在 CloudFormation 管理下使用預設事件匯流排
<a name="related-services-cfn-import-default-bus"></a>

由於 會自動將預設事件匯流排 EventBridge 佈建至您的 帳戶，因此您無法使用 CloudFormation 範本建立它，就像您通常想要包含在堆疊中的任何 CloudFormation 資源一樣。若要在 CloudFormation 堆疊中包含預設事件匯流排，您必須先將其*匯入*堆疊。將預設事件匯流排匯入堆疊後，您可以視需要更新事件匯流排屬性。

如需詳細資訊，請參閱[在 EventBridge AWS CloudFormation 中使用 更新預設事件匯流排](event-bus-update-default-cfn.md)

## 使用 EventBridge 管理 CloudFormation 堆疊事件
<a name="related-services-cfn-stack-events"></a>

除了在 CloudFormation 堆疊中包含 EventBridge 資源之外，您還可以使用 EventBridge 來管理由 CloudFormation 堆疊本身所產生的事件。每當對堆疊執行建立、更新、刪除或漂移偵測作業時，CloudFormation 都會將事件傳送到 EventBridge。CloudFormation 也會針對堆疊集和堆疊集執行個體的狀態變更，將事件傳送至 EventBridge。您可以使用 EventBridge 規則將事件路由至您定義的目標。

如需詳細資訊，請參閱《CloudFormation 使用者指南》**中的[使用 EventBridge 管理 CloudFormation 事件](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacks-event-bridge.html)。