

# 使用 Amazon RDS 事件通知
<a name="USER_Events"></a>

Amazon RDS 使用 Amazon Simple Notification Service (Amazon SNS) 在发生 Amazon RDS 事件时提供通知。这些通知可以采用 AWS 区域 Amazon SNS 支持的任何通知形式，例如电子邮件、文本消息或对 HTTP 终端节点的调用。

**Topics**
+ [Amazon RDS 事件通知概述](USER_Events.overview.md)
+ [授予向 Amazon SNS 主题发布通知的权限。](USER_Events.GrantingPermissions.md)
+ [订阅 Amazon RDS 事件通知](USER_Events.Subscribing.md)
+ [Amazon RDS 事件通知标签和属性](USER_Events.TagsAttributesForFiltering.md)
+ [列出 Amazon RDS 事件通知订阅](USER_Events.ListSubscription.md)
+ [修改 Amazon RDS 事件通知订阅](USER_Events.Modifying.md)
+ [在 Amazon RDS 事件通知订阅中添加源标识符](USER_Events.AddingSource.md)
+ [从 Amazon RDS 事件通知订阅中删除源标识符](USER_Events.RemovingSource.md)
+ [列出 Amazon RDS 事件通知类型](USER_Events.ListingCategories.md)
+ [删除 Amazon RDS 事件通知订阅](USER_Events.Deleting.md)

# Amazon RDS 事件通知概述
<a name="USER_Events.overview"></a>

Amazon RDS 将事件分组为您可以订阅的类型，以便您在出现该类事件时收取通知。

**Topics**
+ [符合事件订阅条件的 RDS 资源](#USER_Events.overview.resources)
+ [订阅 Amazon RDS 事件通知的基本流程](#USER_Events.overview.process)
+ [发送 RDS 事件通知](#USER_Events.overview.subscriptions)
+ [Amazon RDS 事件通知的计费](#USER_Events.overview.billing)
+ [使用 Amazon EventBridge 的 Amazon RDS 事件的示例](#events-examples)

## 符合事件订阅条件的 RDS 资源
<a name="USER_Events.overview.resources"></a>

您可以订阅以下资源的事件类别：
+ 数据库实例
+ 数据库快照
+ 数据库参数组
+ 数据库安全组
+ RDS 代理
+ 自定义引擎版本

例如，如果您订阅给定数据库实例的备份类别，那么无论何时出现影响该数据库实例的备份相关事件，您都将收到通知。如果您订阅对于数据库实例的配置更改类别，则会在数据库实例出现更改时收到通知。您还将在事件通知订阅更改时收到通知。

您可能需要创建多个不同的订阅。例如，您可能创建一个订阅以接收所有数据库实例的所有事件通知，并创建另一个订阅，其中仅包括数据库实例子集的严重事件。对于第二个订阅，请在筛选条件中指定一个或多个数据库实例。

## 订阅 Amazon RDS 事件通知的基本流程
<a name="USER_Events.overview.process"></a>

订阅 Amazon RDS 事件通知的流程如下：

1. 您使用 Amazon RDS 控制台、AWS CLI 或者 API 创建 Amazon RDS 事件通知订阅。

   Amazon RDS 使用 Amazon SNS 主题的 ARN 标识每个订阅。Amazon RDS 控制台在您创建订阅时为您创建 ARN。使用 Amazon SNS 控制台、AWS CLI 或 Amazon SNS API 创建 ARN。

1. Amazon RDS 发送批准电子邮件或者 SMS 消息给您在订阅时提交的地址。

1. 您可以通过选择所收到的通知中的链接来确认您的订阅。

1. Amazon RDS 控制台更新 **My Event Subscriptions**（我的事件订阅）部分，其中包含您的订阅状态。

1. Amazon RDS 开始将通知发送到您在创建订阅时提供的地址。

要了解使用 Amazon SNS 时的 Identity of Access Management，请查看 *Amazon Simple Notification Service 开发人员指南*中的 [Amazon SNS 中的 Identity of Access Management](https://docs.aws.amazon.com/sns/latest/dg/sns-authentication-and-access-control.html)。

您可以使用处理 AWS Lambda 来自数据库实例的事件通知。有关更多信息，请参阅 *AWS Lambda 开发人员指南*中的[将 AWS Lambda 与 Amazon RDS 结合使用](https://docs.aws.amazon.com/lambda/latest/dg/services-rds.html)。

## 发送 RDS 事件通知
<a name="USER_Events.overview.subscriptions"></a>

Amazon RDS 会将通知发送到您在创建订阅时提供的地址。通知可以包含消息属性，以提供有关消息的结构化元数据。有关消息属性的更多信息，请参阅[Amazon RDS 事件类别和事件消息](USER_Events.Messages.md)。

事件通知的传递可能需要长达五分钟。

**重要**  
Amazon RDS 不保证在事件流中发送的事件的顺序。事件顺序可能会发生变化。

当 Amazon SNS 向已经订阅的 HTTP 或 HTTPS 端点发送一条通知时，发至端点的 POST 消息具有包含 JSON 格式文档的消息正文。有关更多信息，请参阅 *Amazon Simple Notification Service 开发人员指南* 中的 [Amazon SNS 消息和 JSON 格式](https://docs.aws.amazon.com/sns/latest/dg/sns-message-and-json-formats.html)。

您可以将 SNS 配置为通过短信通知。有关更多信息，请参阅 *Amazon Simple Notification Service 开发人员指南*中的[移动文本消息 (SMS)](https://docs.aws.amazon.com/sns/latest/dg/sns-mobile-phone-number-as-subscriber.html)。

要在不删除订阅的情况下关闭通知，请在 Amazon RDS 控制台中为**已启用**选择**否**。或者，可以使用 AWS CLI 或 Amazon RDS API 将 `Enabled` 参数设置为 `false`。

## Amazon RDS 事件通知的计费
<a name="USER_Events.overview.billing"></a>

Amazon RDS 事件通知的计费是通过 Amazon SNS 执行的。Amazon SNS 费用在使用事件通知时适用。有关 Amazon SNS 计费的更多信息，请参阅 [Amazon Simple Notification Service 定价](https://aws.amazon.com/sns/#pricing)。

## 使用 Amazon EventBridge 的 Amazon RDS 事件的示例
<a name="events-examples"></a>

以下示例说明了 JSON 格式的不同类型的 Amazon RDS 事件。有关向您说明如何以 JSON 格式捕获和查看事件的教程，请参阅[教程：使用 Amazon EventBridge 记录数据库实例的状态更改](rds-cloud-watch-events.md#log-rds-instance-state)。

**Topics**
+ [数据库实例事件的示例](#rds-cloudwatch-events.db-instances)
+ [数据库参数组事件的示例](#rds-cloudwatch-events.db-parameter-groups)
+ [数据库快照事件的示例](#rds-cloudwatch-events.db-snapshots)

### 数据库实例事件的示例
<a name="rds-cloudwatch-events.db-instances"></a>

以下是采用 JSON 格式的数据库实例事件的示例。该事件显示，RDS 为名为 `my-db-instance` 的实例执行了多可用区故障转移。事件 ID 为 RDS-EVENT-0049。

```
{
  "version": "0",
  "id": "68f6e973-1a0c-d37b-f2f2-94a7f62ffd4e",
  "detail-type": "RDS DB Instance Event",
  "source": "aws.rds",
  "account": "123456789012",
  "time": "2018-09-27T22:36:43Z",
  "region": "us-east-1",
  "resources": [
    "arn:aws:rds:us-east-1:123456789012:db:my-db-instance"
  ],
  "detail": {
    "EventCategories": [
      "failover"
    ],
    "SourceType": "DB_INSTANCE",
    "SourceArn": "arn:aws:rds:us-east-1:123456789012:db:my-db-instance",
    "Date": "2018-09-27T22:36:43.292Z",
    "Message": "A Multi-AZ failover has completed.",
    "SourceIdentifier": "my-db-instance",
    "EventID": "RDS-EVENT-0049"
  }
}
```

### 数据库参数组事件的示例
<a name="rds-cloudwatch-events.db-parameter-groups"></a>

以下是采用 JSON 格式的数据库参数组事件的示例。该事件显示参数 `time_zone` 已在参数组 `my-db-param-group` 中更新。事件 ID 为 RDS-EVENT-0037。

```
{
  "version": "0",
  "id": "844e2571-85d4-695f-b930-0153b71dcb42",
  "detail-type": "RDS DB Parameter Group Event",
  "source": "aws.rds",
  "account": "123456789012",
  "time": "2018-10-06T12:26:13Z",
  "region": "us-east-1",
  "resources": [
    "arn:aws:rds:us-east-1:123456789012:pg:my-db-param-group"
  ],
  "detail": {
    "EventCategories": [
      "configuration change"
    ],
    "SourceType": "DB_PARAM",
    "SourceArn": "arn:aws:rds:us-east-1:123456789012:pg:my-db-param-group",
    "Date": "2018-10-06T12:26:13.882Z",
    "Message": "Updated parameter time_zone to UTC with apply method immediate",
    "SourceIdentifier": "my-db-param-group",
    "EventID": "RDS-EVENT-0037"
  }
}
```

### 数据库快照事件的示例
<a name="rds-cloudwatch-events.db-snapshots"></a>

以下是采用 JSON 格式的数据库快照事件的示例。该事件显示删除名 `my-db-snapshot` 为的快照。事件 ID 为 RDS-EVENT-0041。

```
{
  "version": "0",
  "id": "844e2571-85d4-695f-b930-0153b71dcb42",
  "detail-type": "RDS DB Snapshot Event",
  "source": "aws.rds",
  "account": "123456789012",
  "time": "2018-10-06T12:26:13Z",
  "region": "us-east-1",
  "resources": [
    "arn:aws:rds:us-east-1:123456789012:snapshot:rds:my-db-snapshot"
  ],
  "detail": {
    "EventCategories": [
      "deletion"
    ],
    "SourceType": "SNAPSHOT",
    "SourceArn": "arn:aws:rds:us-east-1:123456789012:snapshot:rds:my-db-snapshot",
    "Date": "2018-10-06T12:26:13.882Z",
    "Message": "Deleted manual snapshot",
    "SourceIdentifier": "my-db-snapshot",
    "EventID": "RDS-EVENT-0041"
  }
}
```

# 授予向 Amazon SNS 主题发布通知的权限。
<a name="USER_Events.GrantingPermissions"></a>

要授予 Amazon RDS 将通知发布到 Amazon Simple Notification Service (Amazon SNS) 主题的权限，请将 AWS Identity and Access Management (IAM) 策略附加到目标主题。有关权限的更多信息，请参阅《Amazon Simple Notification Service 开发人员指南》**中的 [Amazon Simple Notification Service 访问控制示例案例](https://docs.aws.amazon.com/sns/latest/dg/sns-access-policy-use-cases.html)。

原定设置情况下，Amazon SNS 主题具有一项策略，它允许同一账户中的所有 Amazon RDS 资源向其发布通知。您可以附加自定义策略以允许跨账户通知，或限制对某些资源的访问。

以下是您附加到目标 Amazon SNS 主题的 IAM 策略示例。它将主题限制为名称与指定前缀匹配的数据库实例。要使用此策略，请指定以下值：
+ `Resource` – Amazon SNS 主题的 Amazon 资源名称 (ARN)
+ `SourceARN` – 您的 RDS 资源 ARN
+ `SourceAccount` – 您的 AWS 账户 ID

有关资源类型及其 ARN 的列表，请参阅《服务授权参考》**中的 [Amazon RDS 定义的资源](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonrds.html#amazonrds-resources-for-iam-policies)。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "events.rds.amazonaws.com"
      },
      "Action": [
        "sns:Publish"
      ],
      "Resource": "arn:aws:sns:us-east-1:123456789012:topic_name",
      "Condition": {
        "ArnLike": {
          "aws:SourceArn": "arn:aws:rds:us-east-1:123456789012:db:prefix-*"
        },
        "StringEquals": {
          "aws:SourceAccount": "123456789012"
        }
      }
    }
  ]
}
```

------

# 订阅 Amazon RDS 事件通知
<a name="USER_Events.Subscribing"></a>

最简单的订阅创建方法是使用 RDS 控制台。如果您选择使用 CLI 或 API 创建事件通知，则必须创建 Amazon Simple Notification Service 主题并订阅有关 Amazon SNS 控制台或 Amazon SNS API 的主题。您还必须保留该主题的 Amazon Resource Name (ARN)，因为在提交 CLI 命令或者 API 操作时会用到。有关创建和订阅 SNS 主题的信息，请参阅 *Amazon Simple Notification Service 开发人员指南*中的 [Amazon SNS 入门](https://docs.aws.amazon.com/sns/latest/dg/GettingStarted.html)。

您可以指定希望收取其通知的源类型以及触发该事件的 Amazon RDS 源：

**Source type**（源类型）  
源类型。例如，**Source type**（源类型）可能是 **Instances**（实例）。必须选择一种源类型。

***Resources* to include**（要包含的资源）  
生成事件的 Amazon RDS 资源。例如，您可以选择 **Select specific instances**（选择特定实例），然后选择 **myDBInstance1**。

下表说明了指定或不指定 ***Resources* to include**（要包含的资源）时的结果。


|  要包含的资源  |  描述  |  示例  | 
| --- | --- | --- | 
|  指定  |  RDS 仅向您通知指定资源的所有事件。  | 如果 Source type（源类型）为 Instances（实例），资源为 myDBInstance1，则 RDS 仅向您通知 myDBInstance1 的所有事件。 | 
|  未指定  |  RDS 会向您通知所有 Amazon RDS 资源的指定源类型的事件。  |  如果 **Source type**（源类型）是 **Instances**（实例），RDS 会向您通知您的账户中所有与实例相关的事件。  | 

原定设置情况下，Amazon SNS 主题订阅用户会收到发布到该主题的每条消息。要仅接收一部分消息，订阅用户必须将筛选策略分配给主题订阅。有关更多信息，请参阅《Amazon Simple Notification Service 开发人员指南》**中的 [Amazon SNS 消息筛选](https://docs.aws.amazon.com/sns/latest/dg/sns-message-filtering.html)。

## 控制台
<a name="USER_Events.Subscribing.Console"></a>

**订阅 RDS 事件通知**

1. 登录 AWS 管理控制台 并通过以下网址打开 Amazon RDS 控制台：[https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/)。

1. 在导航窗格中，选择**事件订阅**。

1. 在**事件订阅**窗格中，选择**创建事件订阅**。

1. 输入您的订阅详情，如下所示：

   1. 对于**名称**，输入事件通知订阅的名称。

   1. 对于 **Send notifications to**（发送通知到），执行以下操作之一：
      + 选择 **New email topic**（新建电子邮件主题）。输入电子邮件主题的名称和收件人列表。我们建议您将事件订阅配置为与主要账户联系人相同的电子邮件地址。建议、服务事件和个人健康信息是通过不同的渠道发送的。订阅同一个电子邮件地址可确保将所有邮件合并到一个位置。
      + 选择 **Amazon Resource Name (ARN)** [Amazon 资源名称（ARN）]。然后，为 Amazon SNS 主题选择现有的 Amazon SNS ARN。

        如果您想使用已启用服务器端加密 (SSE) 的主题，请向 Amazon RDS 授予访问 AWS KMS key 的必需权限。有关更多信息，请参阅《Amazon Simple Notification Service 开发人员指南》中的[实现 AWS 服务中的事件源与加密主题之间的兼容性](https://docs.aws.amazon.com/sns/latest/dg/sns-key-management.html#compatibility-with-aws-services)。

   1. 对于**源类型**，请选择一种源类型。例如，选择 **Instances**（实例）或 **Parameter groups**（参数组）。

   1. 选择要接收事件通知的事件类别和资源。

      以下示例为名为 `testinst` 的数据库实例配置事件通知。  
![\[输入源类型\]](http://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/UserGuide/images/event-source.png)

   1. 选择**创建**。

Amazon RDS 控制台会表明正在创建订阅。

![\[列出数据库事件通知订阅\]](http://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/UserGuide/images/EventNotification-Create2.png)


## AWS CLI
<a name="USER_Events.Subscribing.CLI"></a>

要订阅 RDS 事件通知，请使用 AWS CLI [https://docs.aws.amazon.com/cli/latest/reference/rds/create-event-subscription.html](https://docs.aws.amazon.com/cli/latest/reference/rds/create-event-subscription.html) 命令。包括以下必需参数：
+ `--subscription-name`
+ `--sns-topic-arn`

**Example**  
对于 Linux、macOS 或 Unix：  

```
aws rds create-event-subscription \
    --subscription-name myeventsubscription \
    --sns-topic-arn arn:aws:sns:us-east-1:123456789012:myawsuser-RDS \
    --enabled
```
对于 Windows：  

```
aws rds create-event-subscription ^
    --subscription-name myeventsubscription ^
    --sns-topic-arn arn:aws:sns:us-east-1:123456789012:myawsuser-RDS ^
    --enabled
```

## API
<a name="USER_Events.Subscribing.API"></a>

要订阅 Amazon RDS 事件通知，请调用 Amazon RDS API 函数 [https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateEventSubscription.html](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateEventSubscription.html)。包括以下必需参数：
+ `SubscriptionName`
+ `SnsTopicArn`

# Amazon RDS 事件通知标签和属性
<a name="USER_Events.TagsAttributesForFiltering"></a>

当 Amazon RDS 向 Amazon Simple Notification Service（SNS）或 Amazon EventBridge 发送事件通知时，通知包含消息属性和事件标签。RDS 将消息属性与消息一起单独发送，而事件标签位于消息正文中。使用消息属性和 Amazon RDS 标签将元数据添加到您的资源中。您可以使用您自己的关于数据库实例的表示法来修改这些标签。有关标记 Amazon RDS 资源的更多信息，请参阅[为 Amazon RDS 资源添加标签](USER_Tagging.md)。

默认情况下，Amazon SNS 和 Amazon EventBridge 会接收发送给它们的每条消息。SNS 和 EventBridge 可以筛选消息，并将通知发送到首选的通信模式，例如电子邮件、短信或对 HTTP 端点的调用。

**注意**  
通过电子邮件或短信发送的通知将没有事件标签。

下表显示了发送给主题订阅用户的 RDS 事件的消息属性。


| Amazon RDS 事件属性 |  说明  | 
| --- | --- | 
| EventID |  RDS 事件消息的标识符，例如 RDS-EVENT-0006。  | 
| 资源 |  发出事件的资源的 ARN 标识符，例如 `arn:aws:rds:ap-southeast-2:123456789012:db:database-1`。  | 

RDS 标签提供有关受服务事件影响的资源的数据。当通知发送到 SNS 或 EventBridge 时，RDS 会在消息正文中添加标签的当前状态。

有关筛选 SNS 的消息属性的更多信息，请参阅《Amazon Simple Notification Service 开发人员指南》**中的 [Amazon SNS 消息筛选](https://docs.aws.amazon.com/sns/latest/dg/sns-message-filtering.html)。

有关筛选 EventBridge 的事件标签的更多信息，请参阅《Amazon EventBridge 用户指南》**中的 [Comparison operators for use in event patterns in Amazon EventBridge](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns-content-based-filtering.html)。

有关筛选 SNS 的基于有效载荷的标签的更多信息，请参阅 [Introducing payload-based message filtering for Amazon SNS](https://aws.amazon.com/blogs/compute/introducing-payload-based-message-filtering-for-amazon-sns/)

# 列出 Amazon RDS 事件通知订阅
<a name="USER_Events.ListSubscription"></a>

您可以列出当前的 Amazon RDS 事件通知订阅。

## 控制台
<a name="USER_Events.ListSubscription.Console"></a>

**列出当前的 Amazon RDS 事件通知订阅**

1. 登录 AWS 管理控制台 并通过以下网址打开 Amazon RDS 控制台：[https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/)。

1.  在导航窗格中，选择**事件订阅**。**事件订阅**窗格中会显示您的所有事件通知订阅。  
![\[列出数据库事件通知订阅\]](http://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/UserGuide/images/EventNotification-ListSubs.png)

   

## AWS CLI
<a name="USER_Events.ListSubscription.CLI"></a>

要列出当前的 Amazon RDS 事件通知订阅，请使用 AWS CLI [https://docs.aws.amazon.com/cli/latest/reference/rds/describe-event-subscriptions.html](https://docs.aws.amazon.com/cli/latest/reference/rds/describe-event-subscriptions.html) 命令。

**Example**  
以下示例描述所有事件订阅。  

```
aws rds describe-event-subscriptions
```
以下示例描述 `myfirsteventsubscription`。  

```
aws rds describe-event-subscriptions --subscription-name myfirsteventsubscription
```

## API
<a name="USER_Events.ListSubscription.API"></a>

要列出当前的 Amazon RDS 事件通知订阅，请调用 Amazon RDS API [https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeEventSubscriptions.html](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeEventSubscriptions.html) 操作。

# 修改 Amazon RDS 事件通知订阅
<a name="USER_Events.Modifying"></a>

创建订阅后，您可以更改订阅名称、源标识符、类别或主题 ARN。

## 控制台
<a name="USER_Events.Modifying.Console"></a>

**修改 Amazon RDS 事件通知订阅**

1. 登录 AWS 管理控制台 并通过以下网址打开 Amazon RDS 控制台：[https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/)。

1.  在导航窗格中，选择**事件订阅**。

1.  在**事件订阅**窗格中，选择您要修改的订阅，然后选择**编辑**。

1.  在**目标**或**来源**部分中对订阅进行更改。

1. 选择**编辑**。Amazon RDS 控制台会表明正在修改订阅。  
![\[列出数据库事件通知订阅\]](http://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/UserGuide/images/EventNotification-Modify2.png)

   

## AWS CLI
<a name="USER_Events.Modifying.CLI"></a>

要修改 Amazon RDS 事件通知订阅，请使用 AWS CLI [https://docs.aws.amazon.com/cli/latest/reference/rds/modify-event-subscription.html](https://docs.aws.amazon.com/cli/latest/reference/rds/modify-event-subscription.html) 命令。包括以下必需参数：
+ `--subscription-name`

**Example**  
以下代码实现 `myeventsubscription`。  
对于 Linux、macOS 或 Unix：  

```
aws rds modify-event-subscription \
    --subscription-name myeventsubscription \
    --enabled
```
对于 Windows：  

```
aws rds modify-event-subscription ^
    --subscription-name myeventsubscription ^
    --enabled
```

## API
<a name="USER_Events.Modifying.API"></a>

要修改 Amazon RDS 事件，请调用 Amazon RDS API 操作 [https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_ModifyEventSubscription.html](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_ModifyEventSubscription.html)。包括以下必需参数：
+ `SubscriptionName`

# 在 Amazon RDS 事件通知订阅中添加源标识符
<a name="USER_Events.AddingSource"></a>

您可以给现有的订阅添加源标识符 (生成事件的 Amazon RDS 源)。

## 控制台
<a name="USER_Events.AddingSource.Console"></a>

您可以使用 Amazon RDS 控制台在修改订阅时通过选择或者取消选择操作轻松地添加或删除源标识符。有关更多信息，请参阅“[修改 Amazon RDS 事件通知订阅](USER_Events.Modifying.md)”。

## AWS CLI
<a name="USER_Events.AddingSource.CLI"></a>

要将源标识符添加到 Amazon RDS 事件通知订阅，请使用 AWS CLI [https://docs.aws.amazon.com/](https://docs.aws.amazon.com/) 命令。包括以下必需参数：
+ `--subscription-name`
+ `--source-identifier`

**Example**  
以下示例将源标识符 `mysqldb` 添加到 `myrdseventsubscription` 订阅。  
对于 Linux、macOS 或 Unix：  

```
aws rds add-source-identifier-to-subscription \
    --subscription-name myrdseventsubscription \
    --source-identifier mysqldb
```
对于：Windows  

```
aws rds add-source-identifier-to-subscription ^
    --subscription-name myrdseventsubscription ^
    --source-identifier mysqldb
```

## API
<a name="USER_Events.AddingSource.API"></a>

要将源标识符添加到 Amazon RDS 事件通知订阅，请调用 Amazon RDS API [https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_AddSourceIdentifierToSubscription.html](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_AddSourceIdentifierToSubscription.html)。包括以下必需参数：
+ `SubscriptionName`
+ `SourceIdentifier`

# 从 Amazon RDS 事件通知订阅中删除源标识符
<a name="USER_Events.RemovingSource"></a>

如果您不再希望收到源的事件通知，可以从订阅中删除源标识符 (生成事件的 Amazon RDS 源)。

## 控制台
<a name="USER_Events.RemovingSource.Console"></a>

您可以使用 Amazon RDS 控制台在修改订阅时通过选择或者取消选择操作轻松地添加或删除源标识符。有关更多信息，请参阅“[修改 Amazon RDS 事件通知订阅](USER_Events.Modifying.md)”。

## AWS CLI
<a name="USER_Events.RemovingSource.CLI"></a>

要从 Amazon RDS 事件通知订阅删除源标识符，请使用 AWS CLI [https://docs.aws.amazon.com/cli/latest/reference/rds/remove-source-identifier-from-subscription.html](https://docs.aws.amazon.com/cli/latest/reference/rds/remove-source-identifier-from-subscription.html) 命令。包括以下必需参数：
+ `--subscription-name`
+ `--source-identifier`

**Example**  
以下示例将从 `mysqldb` 订阅中删除源标识符 `myrdseventsubscription`。  
对于 Linux、macOS 或 Unix：  

```
aws rds remove-source-identifier-from-subscription \
    --subscription-name myrdseventsubscription \
    --source-identifier mysqldb
```
对于：Windows  

```
aws rds remove-source-identifier-from-subscription ^
    --subscription-name myrdseventsubscription ^
    --source-identifier mysqldb
```

## API
<a name="USER_Events.RemovingSource.API"></a>

要从 Amazon RDS 事件通知订阅删除源标识符，请使用 Amazon RDS API [https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_RemoveSourceIdentifierFromSubscription.html](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_RemoveSourceIdentifierFromSubscription.html) 命令。包括以下必需参数：
+ `SubscriptionName`
+ `SourceIdentifier`

# 列出 Amazon RDS 事件通知类型
<a name="USER_Events.ListingCategories"></a>

资源类型的所有事件都可以分组为类型。要查看可用类型的列表，请使用下列步骤。

## 控制台
<a name="USER_Events.ListingCategories.Console"></a>

当创建或者修改事件通知订阅时，事件类型会显示在 Amazon RDS 控制台中。有关更多信息，请参阅“[修改 Amazon RDS 事件通知订阅](USER_Events.Modifying.md)”。

![\[列出数据库事件通知类别\]](http://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/UserGuide/images/EventNotification-Categories.png)




## AWS CLI
<a name="USER_Events.ListingCategories.CLI"></a>

要列出 Amazon RDS 事件通知类别，请使用 AWS CLI [https://docs.aws.amazon.com/cli/latest/reference/rds/describe-event-categories.html](https://docs.aws.amazon.com/cli/latest/reference/rds/describe-event-categories.html) 命令。此命令没有必需参数。

**Example**  

```
aws rds describe-event-categories
```

## API
<a name="USER_Events.ListingCategories.API"></a>

要列出 Amazon RDS 事件通知类别，请使用 Amazon RDS API [https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeEventCategories.html](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeEventCategories.html) 命令。此命令没有必需参数。

# 删除 Amazon RDS 事件通知订阅
<a name="USER_Events.Deleting"></a>

当您不再需要时，可以删除订阅。该主题的所有用户都将再也不会收到订阅指定的事件通知。

## 控制台
<a name="USER_Events.Deleting.Console"></a>

**删除 Amazon RDS 事件通知订阅**

1. 登录 AWS 管理控制台 并通过以下网址打开 Amazon RDS 控制台：[https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/)。

1.  在导航窗格中，选择**数据库事件订阅**。

1.  在**我的数据库事件订阅**窗格中，选择您希望删除的订阅。

1. 选择 **Delete**。

1. Amazon RDS 控制台会表明正在删除订阅。  
![\[删除事件通知订阅\]](http://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/UserGuide/images/EventNotification-Delete.png)

   

## AWS CLI
<a name="USER_Events.Deleting.CLI"></a>

要删除 Amazon RDS 事件通知订阅，请使用 AWS CLI [https://docs.aws.amazon.com/cli/latest/reference/rds/delete-event-subscription.html](https://docs.aws.amazon.com/cli/latest/reference/rds/delete-event-subscription.html) 命令。包括以下必需参数：
+ `--subscription-name`

**Example**  
以下示例删除订阅 `myrdssubscription`。  

```
aws rds delete-event-subscription --subscription-name myrdssubscription
```

## API
<a name="USER_Events.Deleting.API"></a>

要删除 Amazon RDS 事件通知订阅，请使用 RDS API [https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DeleteEventSubscription.html](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DeleteEventSubscription.html) 命令。包括以下必需参数：
+ `SubscriptionName`