

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

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

Amazon RDS 使用 Amazon Simple Notification Service (Amazon SNS) 在 Amazon RDS 事件發生時提供通知。這些通知可以採用任何 Amazon SNS 在 AWS 區域中支援的通知形式，例如電子郵件、文字訊息或呼叫 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 的 Aurora 事件範例](#events-examples)

## 符合事件訂閱資格的 RDS 資源
<a name="USER_Events.overview.resources"></a>

對 Amazon Aurora 來說，事件發生於資料庫叢集和資料庫執行個體層級。您可以針對下列資源訂閱事件類別：
+ 資料庫執行個體
+ 資料庫叢集
+ 資料庫叢集快照
+ DB parameter group (資料庫參數群組)
+ 資料庫安全群組
+ RDS Proxy
+ 自訂引擎版本

例如，如果您訂閱指定資料庫執行個體的備份類別，當發生會影響資料庫執行個體的備份相關事件時，您將會收到通知。如果您訂閱資料庫執行個體的組態變更類別，當資料庫執行個體變更時，您將會收到通知。當事件通知訂閱變更時，您也會收到通知。

您可能會想要建立數個不同的訂閱。例如，您可能會建立一個訂閱以接收所有資料庫執行個體的所有事件通知，並建立另一個訂閱以僅包含資料庫執行個體子集的重要事件。對於第二個訂閱，請在篩選條件中指定一或多個資料庫執行個體。

## 訂閱 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 and Access Management，請參閱《*Amazon Simple Notification Service 開發人員指南*》中的 [Amazon SNS 中的 Identity and 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 會將通知傳送到您在建立訂閱時提供的地址。通知可以包含訊息屬性，其會提供有關訊息的結構化中繼資料。如需訊息屬性的詳細資訊，請參閱 [Aurora 的 Amazon RDS 事件類別和事件訊息](USER_Events.Messages.md)

事件通知的傳送可能需要 5 分鐘。

**重要**  
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 主控台中，為 **Enabled** (啟用) 選擇 **No** (否)。或者，您可以使用 AWS CLI 或 Amazon RDS API `false` 將 `Enabled` 參數設定為 。

## 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 的 Aurora 事件範例
<a name="events-examples"></a>

下列範例以 JSON 格式說明不同類型的 Aurora 事件。如需演示如何擷取和檢視 JSON 格式事件的教學課程，請參閱 [教學課程：使用 Amazon EventBridge 來記錄資料庫執行個體狀態變更](rds-cloud-watch-events.md#log-rds-instance-state)。

**Topics**
+ [資料庫叢集事件範例](#rds-cloudwatch-events.db-clusters)
+ [資料庫參數群組事件的範例](#rds-cloudwatch-events.db-parameter-groups)
+ [資料庫叢集快照事件範例](#rds-cloudwatch-events.db-cluster-snapshots)

### 資料庫叢集事件範例
<a name="rds-cloudwatch-events.db-clusters"></a>

以下是 JSON 格式的資料庫叢集事件範例。此事件顯示名為 `my-db-cluster` 的叢集已修補。事件 ID 是 `RDS-EVENT-0173`。

```
{
  "version": "0",
  "id": "844e2571-85d4-695f-b930-0153b71dcb42",
  "detail-type": "RDS DB Cluster Event",
  "source": "aws.rds",
  "account": "123456789012",
  "time": "2018-10-06T12:26:13Z",
  "region": "us-east-1",
  "resources": [
    "arn:aws:rds:us-east-1:123456789012:cluster:my-db-cluster"
  ],
  "detail": {
    "EventCategories": [
      "notification"
    ],
    "SourceType": "CLUSTER",
    "SourceArn": "arn:aws:rds:us-east-1:123456789012:cluster:my-db-cluster",
    "Date": "2018-10-06T12:26:13.882Z",
    "Message": "Database cluster has been patched",
    "SourceIdentifier": "my-db-cluster",
    "EventID": "RDS-EVENT-0173"
  }
}
```

### 資料庫參數群組事件的範例
<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-cluster-snapshots"></a>

以下是 JSON 格式的資料庫叢集快照事件範例。此事件會顯示建立名為 `my-db-cluster-snapshot` 的快照。事件 ID 是 RDS-EVENT-0074。

```
{
  "version": "0",
  "id": "844e2571-85d4-695f-b930-0153b71dcb42",
  "detail-type": "RDS DB Cluster 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:cluster-snapshot:rds:my-db-cluster-snapshot"
  ],
  "detail": {
    "EventCategories": [
      "backup"
    ],
    "SourceType": "CLUSTER_SNAPSHOT",
    "SourceArn": "arn:aws:rds:us-east-1:123456789012:cluster-snapshot:rds:my-db-cluster-snapshot",
    "Date": "2018-10-06T12:26:13.882Z",
    "SourceIdentifier": "my-db-cluster-snapshot",
    "Message": "Creating manual cluster snapshot",
    "EventID": "RDS-EVENT-0074"
  }
}
```

# 授予將通知發佈至 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 Resource Name (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** (執行個體)。您必須選擇來源類型。

**要包含的*資源***  
正在產生事件的 Amazon RDS 資源。例如，您可以選擇 **Select specific instances** (選取特定執行個體) 然後選擇 **myDBInstane1**。

下表說明了指定或不指定**要包含的*資源***時的結果。


|  要包含的資源  |  描述  |  範例  | 
| --- | --- | --- | 
|  指定  |  RDS 只會通知您指定資源的所有資料庫執行個體事件。  | 如果您的 Source type (來源類型) 是 Instances (執行個體)，您的資源是 myDBInstance1，RDS 只會通知您有關 myDBInstance1。 | 
|  未指定  |  您會收到所有 Amazon RDS 資源中指定來源類型事件的通知。  |  如果您的 **Source type** (來源類型) 是 **Instances** (執行個體)，RDS 會通知您帳戶中所有與執行個體相關的事件。  | 

根據預設，Amazon SNS 主題訂閱者會接收發佈到主題的每個訊息。若要僅接收一部分的訊息，訂閱者必須將篩選政策指派給主題訂閱。如需有關 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 管理主控台，開啟位於 [https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/) 的 Amazon RDS 主控台。

1. 在導覽窗格中，選擇 **Event subscriptions** (事件訂閱)。

1. 在 **Event subscriptions (事件訂閱)** 窗格中，選擇 **Create event subscription (建立事件訂閱)**。

1. 輸入您的訂閱詳細資訊，如下所示：

   1. 在 **Name (名稱)** 中，輸入事件通知訂閱的名稱。

   1. 對於 **Send notification to:** (傳送通知給：)，執行以下其中一項：
      + 選擇 **New email topic** (新的電子郵件主題)。輸入電子郵件主題的名稱和收件者清單。建議您將事件訂閱設定為與主要帳戶聯絡人相同的電子郵件地址。建議、服務事件和個人健康訊息會使用不同的通道傳送。訂閱相同電子郵件地址可確保所有郵件都合併在一個位置。
      + 選擇 **Amazon Resource Name (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. 在 **Source type (來源類型)** 中選擇來源類型。例如，選擇  **Cluster** (叢集) 或 **Cluster snapshots** (叢集快照)。

   1. 選擇您要接收通知的事件類型和資源。

      下列範例設定名為 `testinst` 之資料庫執行個體的事件通知。  
![\[輸入來源類型\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/images/event-source.png)

   1. 選擇 **Create** (建立)。

Amazon RDS 主控台顯示正在建立訂閱。

![\[列出資料庫事件通知訂閱\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/images/EventNotification-Create2.png)


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

使用 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) 命令來訂閱 RDS 事件通知。包含下列必要參數：
+ `--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 標籤，將中繼資料新增至資源。您可以使用關於資料庫執行個體、Aurora 叢集等的表示法。如需標記 Amazon RDSAurora 資源的詳細資訊，請參閱 [標記 Amazon Aurora 和 Amazon RDS 資源](USER_Tagging.md)。

根據預設，Amazon SNS 和 Amazon EventBridge 會接收傳送給它們的每則訊息。SNS 和 EventBridge 可以篩選訊息並將通知傳送到偏好的通訊模式，例如電子郵件、簡訊或呼叫 HTTP 端點。

**注意**  
透過電子郵件或簡訊傳送的通知不會有事件標籤。

下表顯示傳送到主題訂閱者的 RDS 事件的訊息屬性。


| Amazon RDS 事件屬性 |  Description  | 
| --- | --- | 
| 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 使用者指南》**中的[在 Amazon EventBridge 中用於事件模式的比較運算子](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns-content-based-filtering.html)。

如需篩選 SNS 承載型標籤的詳細資訊，請參閱 [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 管理主控台，開啟位於 [https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/) 的 Amazon RDS 主控台。

1.  在導覽窗格中，選擇 **Event subscriptions** (事件訂閱)。**Event subscriptions (事件訂閱)** 窗格顯示所有事件通知訂閱。  
![\[列出資料庫事件通知訂閱\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/images/EventNotification-ListSubs.png)

   

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

使用 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) 命令來列出您目前的 Amazon RDS 事件通知訂閱。

**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 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 事件通知訂閱。

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

在您建立訂閱之後，您可以變更訂閱名稱、來源識別碼、類別或主題 ARN。

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

**修改 Amazon RDS 事件通知訂閱**

1. 登入 AWS 管理主控台，開啟位於 [https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/) 的 Amazon RDS 主控台。

1.  在導覽窗格中，選擇 **Event subscriptions** (事件訂閱)。

1.  在 **Event subscriptions (事件訂閱)** 窗格中，選擇您要修改的訂閱，然後選擇 **Edit (編輯)**。

1.  在 **Target (目標)** 或 **Source (來源)** 區段中，對訂閱進行變更。

1. 選擇**編輯**。Amazon RDS 主控台顯示正在修改訂閱。  
![\[列出資料庫事件通知訂閱\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/images/EventNotification-Modify2.png)

   

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

使用 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) 命令來修改 Amazon RDS 事件通知訂閱。包含下列必要參數：
+ `--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 API [https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_AddSourceIdentifierToSubscription.html](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_AddSourceIdentifierToSubscription.html) 將來源識別碼新增至 Amazon RDS 事件通知訂閱。包含下列必要參數：
+ `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 API [https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_RemoveSourceIdentifierFromSubscription.html](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_RemoveSourceIdentifierFromSubscription.html) 命令將來源識別碼從 Amazon RDS 事件通知訂閱中移除。包含下列必要參數：
+ `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_tw/AmazonRDS/latest/AuroraUserGuide/images/EventNotification-Categories.png)




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

使用 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) 命令來列出 Amazon RDS 事件通知訂閱類別。此命令沒有要求的參數。

**Example**  

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

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

使用 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 事件通知訂閱類別。此命令沒有要求的參數。

# 刪除 Amazon RDS 事件通知訂閱
<a name="USER_Events.Deleting"></a>

您可以刪除不再需要的訂閱。該主題的所有訂閱者將不會再收到該訂閱指定的事件通知。

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

**刪除 Amazon RDS 事件通知訂閱**

1. 登入 AWS 管理主控台，開啟位於 [https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/) 的 Amazon RDS 主控台。

1.  在導覽窗格中，選擇 **DB Event Subscriptions** (資料庫事件訂閱)。

1.  在 **My DB Event Subscriptions (我的資料庫事件訂閱)** 窗格中，選擇您要刪除的訂閱。

1. 選擇 **刪除**。

1. Amazon RDS 主控台顯示正在刪除訂閱。  
![\[刪除事件通知訂閱\]](http://docs.aws.amazon.com/zh_tw/AmazonRDS/latest/AuroraUserGuide/images/EventNotification-Delete.png)

   

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

使用 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) 命令來刪除 Amazon RDS 事件通知訂閱。包含下列必要參數：
+ `--subscription-name`

**Example**  
以下範例刪除訂閱 `myrdssubscription`。  

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

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

使用 RDS API [https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DeleteEventSubscription.html](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DeleteEventSubscription.html) 命令來刪除 Amazon RDS 事件通知訂閱。包含下列必要參數：
+ `SubscriptionName`