

# 启用 Amazon EventBridge
<a name="enable-event-notifications-eventbridge"></a>

您可以通过 S3 控制台、AWS Command Line Interface（AWS CLI）或 Amazon S3 REST API 启用 Amazon EventBridge。

**注意**  
在启用 EventBridge 后，所做的更改需要大约五分钟才能生效。

## 使用 S3 控制台
<a name="eventbridge-console"></a>

**在 S3 控制台中启用 EventBridge 事件传输。**

1. 登录到 AWS 管理控制台，然后通过以下网址打开 Amazon S3 控制台：[https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/)。

1. 在左侧导航窗格中，选择**通用存储桶**。

1. 在存储桶列表中，选择要为其启用事件的存储桶的名称。

1. 选择**属性**。

1. 导航到 **Event Notifications**（事件通知）章节，然后找到 **Amazon EventBridge** 小节。请选择**编辑**。

1. 在 **Send notifications to Amazon EventBridge for all events in this bucket**（为此存储桶中的所有事件向 Amazon EventBridge 发送通知）下方，请选择 **On**（打开）。

## 使用 AWS CLI
<a name="eventbridge-cli"></a>

以下示例为启用了 Amazon EventBridge 的存储桶 *`amzn-s3-demo-bucket1`* 创建存储桶通知配置。

```
aws s3api put-bucket-notification-configuration --bucket amzn-s3-demo-bucket1 --notification-configuration='{ "EventBridgeConfiguration": {} }'
```

## 使用 REST API
<a name="eventbridge-api"></a>

您可以通过调用 Amazon S3 REST API 以编程方式在存储桶上启用 Amazon EventBridge。有关更多信息，请参阅《Amazon Simple Storage Service API 参考》**中的 [https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketNotificationConfiguration.html](https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketNotificationConfiguration.html)。

下面的例子展示了在启用 Amazon EventBridge 的情况下，用来创建存储桶通知配置的 XML。

```
<NotificationConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
  <EventBridgeConfiguration>
  </EventBridgeConfiguration>
</NotificationConfiguration>
```

## 创建 EventBridge 规则
<a name="ev-tutorial"></a>

启用后，您可以为某些任务创建 Amazon EventBridge 规则。例如，您可以在创建对象时发送电子邮件通知。有关完整的教程，请参阅 *Amazon EventBridge User Guide*（Amazon EventBridge 用户指南）中的 [Tutorial: Send a notification when an Amazon S3 object is created](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-s3-object-created-tutorial.html)（教程：创建 Amazon S3 对象时发送通知）。