

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 在 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)

  模板示例包括：
  + [为创建 API 目标 PagerDuty](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::Event架构](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>

为了帮助您快速开始开发 CloudFormation 模板， EventBridge 控制台允许您根据账户中的现有事件总线、规则和管道创建 CloudFormation 模板。
+ [从现有 EventBridge 的事件总线生成 CloudFormation 模板](eb-generate-event-bus-template.md)
+ [EventBridge 根据现有规则生成 AWS CloudFormation 模板](rule-generate-template.md)
+ [从 Pi CloudFormation p EventBridge es 生成模板](pipes-generate-template.md)

## 将默认事件总线置于 CloudFormation 管理之下
<a name="related-services-cfn-import-default-bus"></a>

由于 EventBridge 会自动将默认事件总线置备到您的账户中，因此您无法像往常一样使用 CloudFormation 模板来创建它，就像您要包含在 CloudFormation 堆栈中的任何资源一样。要将默认事件总线包含在 CloudFormation 堆栈中，必须先将其*导*入堆栈。将默认事件总线导入堆栈后，即可根据需要更新事件总线属性。

有关更多信息，请参阅 [使用 AWS CloudFormation 中的更新默认事件总线 EventBridge](event-bus-update-default-cfn.md)。

## 使用管理 CloudFormation 堆栈事件 EventBridge
<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)。