

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

# 使用 Amazon EventBridge 整合 AWS 支援 到事件驅動型應用程式
<a name="eventbridge-integration"></a>

您可以將 AWS 支援 納入事件驅動型應用程式 (EDAs)，該應用程式使用 中發生的事件 AWS 支援 ，在應用程式元件之間進行通訊並啟動下游程序。

例如，當您的帳戶發生下列 AWS 支援 事件時，您會收到通知：
+ 建立、解決或重新開啟支援案例
+ 通訊會新增至現有的支援案例

您可以使用 Amazon EventBridge 將事件從 路由 AWS 支援 到其他軟體元件來執行此操作。Amazon EventBridge 是一種無伺服器服務，使用事件將應用程式元件連接在一起，讓您更輕鬆地將 等 AWS 服務整合 AWS 支援 到事件驅動型架構中，而無需額外的程式碼和操作。

## EventBridge 如何路由 AWS 支援 事件
<a name="eventbridge-routes-service-events-aws.support"></a>

以下是 EventBridge 使用 AWS 支援 事件的方式：

如同許多 AWS 服務， AWS 支援 會產生事件並將其傳送至 EventBridge 預設*事件匯流排*。事件匯流排是接收事件並將其路由至您指定目的地或*目標*的路由器。目標可以包含其他服務 AWS 、自訂應用程式和 SaaS 合作夥伴應用程式。

EventBridge 會根據您在事件匯流排上建立的*規則*路由事件。對於每個規則，您可以指定篩選條件或*事件模式*，以僅選取您想要的事件。每當事件傳送到事件匯流排時，EventBridge 都會將其與每個規則進行比較。如果事件符合規則，EventBridge 會將事件路由到指定的目標 (s)。

![\[AWS 服務會將事件傳送至 EventBridge 預設事件匯流排。如果事件符合規則的事件模式，EventBridge 會將事件路由至該規則指定的目標。\]](http://docs.aws.amazon.com/zh_tw/awssupport/latest/user/images/eventbridge-integration-how-it-works.png)


## AWS 支援 事件
<a name="supported-events"></a>

AWS 支援 會自動將下列事件傳送至預設 EventBridge 事件匯流排。


| 事件詳細資訊類型 | Description | 
| --- | --- | 
|  [支援案例更新](event-detail-support-case-update.md)  |  代表支援案例中的變更。  | 

### 事件結構
<a name="eventbridge-event-structure"></a>

 AWS 服務中的所有事件都包含兩種類型的資料：
+ 包含事件中繼資料的常見欄位集，例如事件來源 AWS 的服務、產生事件的時間、事件發生的帳戶和區域，以及其他。如需這些一般欄位的定義，請參閱《*Amazon EventBridge Events Reference*》中的事件[結構](https://docs.aws.amazon.com/eventbridge/latest/ref/overiew-event-structure.html)。
+ 包含該特定服務事件特定資料`detail`的欄位。

### AWS 支援 透過 交付事件 AWS CloudTrail
<a name="eventbridge-events-via-cloudtrail"></a>

AWS 服務可以直接將事件傳送到 EventBridge 預設事件匯流排。此外， 也會 AWS CloudTrail 將來自許多 AWS 服務的事件傳送至 EventBridge。這些事件可能包括 API 呼叫、主控台登入和動作、服務事件和 CloudTrail Insights。如需詳細資訊，請參閱*EventBridge 使用者指南*》中的[AWS 透過 傳遞的服務事件 AWS CloudTrail](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-service-event-cloudtrail.html)。

如需傳送至 EventBridge AWS 支援 的事件清單，請參閱 [https://docs.aws.amazon.com/eventbridge/latest/ref/welcome.html](https://docs.aws.amazon.com/eventbridge/latest/ref/welcome.html) 中的 AWS 支援 主題。

## 建立符合事件 AWS 支援 的事件模式
<a name="eventbridge-event-delivery-filter"></a>

事件模式是篩選條件，其中指定您要選取之事件應有的資料。

每個事件模式都是 JSON 物件，它包含：
+ 識別傳送事件之服務的 `source` 屬性。對於 AWS 支援 事件，來源為 `aws.support`。
+ （選用）：包含要比對之事件名稱陣列的`detail-type`屬性。
+ (選擇性)：包含要比對的任何其他事件資料的 `detail` 屬性。

例如，下列事件模式會從 選取所有支援案例更新事件 AWS 支援：

```
{
  "source": ["aws.support"],
  "detail-type": ["Support Case Update"]
}
```

您可以透過在事件本身中包含值，在事件選擇中取得更具體的內容。例如，下列事件模式符合代表要重新開啟之案例的支援案例更新事件：

```
{
  "source": ["aws.support"],
  "detail-type": ["Support Case Update"],
  "detail": {
      "event-name": "ReopenCase"
    }
}
```

如需撰寫事件模式的詳細資訊，請參閱《*EventBridge 使用者指南*》中的事件[模式](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html)。

### 另請參閱
<a name="see-also-eventbridge-support"></a>

如需如何使用 EventBridge 搭配 的詳細資訊 AWS 支援，請參閱下列資源：
+ [如何使用 Amazon EventBridge 自動化 AWS 支援 API](https://aws.amazon.com/blogs/mt/how-to-automate-aws-support-api-with-amazon-eventbridge)
+ GitHub 上的[AWS 支援 案例活動通知程式](https://github.com/aws-samples/aws-support-case-activity-notifier) 

# 支援案例更新事件
<a name="event-detail-support-case-update"></a>

以下是`Support Case Update`事件的詳細資訊欄位。

以下包含 `source`和 `detail-type` 欄位，因為它們包含 AWS 支援 事件的特定值。如需所有事件中包含的其他中繼資料欄位的定義，請參閱《*Amazon EventBridge 事件參考*》中的[事件結構](https://docs.aws.amazon.com/eventbridge/latest/ref/overiew-event-structure.html)。

```
{
  . . .,
  "detail-type": "Support Case Update",
  "source": "aws.support",
  . . .,
  "detail": {
    "case-id" : "string",
    "display-id" : "string",
    "communication-id" : "string",
    "event-name" : "string",
    "origin" : "string"
  }
}
```

`detail-type`  <a name="support-case-update-detail-type"></a>
識別事件的類型。  
對於此事件，此值為 `Support Case Update`。

`source`  <a name="support-case-update-source"></a>
識別產生事件的服務。對於 AWS 支援 事件，此值為 `aws.support`。

`detail`  <a name="support-case-update-detail"></a>
包含事件相關資訊的 JSON 物件。產生事件的服務會決定此欄位的內容。  
對於此事件，此資料包含：    
`case-id`  <a name="support-case-update-case-id"></a>
支援案例 ID。案例 ID 是以下格式的英數字串：case-*12345678910-2013-c4c1d2bf33c5cf47*。  
`display-id`  <a name="support-case-update-display-id"></a>
 AWS 支援 中心頁面上案例的識別符。  
`communication-id`  <a name="support-case-update-communication-id"></a>
通訊 ID。  
`event-name`  <a name="support-case-update-event-name"></a>
*有效值*：`CreateCase` \$1 `AddCommunicationToCase` \$1 `ResolveCase` \$1 `ReopenCase`  
指定支援案例事件的類型。  
`origin`  <a name="support-case-update-origin"></a>
*有效值*：`AWS` \$1 `CUSTOMER`  
指定您或 AWS 支援 客服人員是否將案例通訊新增至支援案例。  
目前，只有具有 `event-name`的 事件`AddCommunicationToCase`才會包含此值。

**Example 支援案例更新事件範例：已建立支援案例**  <a name="event-detail-support-case-update.example-1"></a>

```
{
    "version": "0",
    "id": "3433df007-9285-55a3-f6d1-536944be45d7",
    "detail-type": "Support Case Update",
    "source": "aws.support",
    "account": "111122223333",
    "time": "2022-02-21T15:51:19Z",
    "region": "us-east-1",
    "resources": [],
    "detail": {
        "case-id": "case-111122223333-muen-2022-7118885805350839",
        "display-id": "1234563851",
        "communication-id": "",
        "event-name": "CreateCase",
        "origin": ""
    }
}
```

**Example 支援案例更新事件範例：支援案例的 AWS 支援 回應**  <a name="event-detail-support-case-update.example-2"></a>

```
{
    "version": "0",
    "id": "f90cb8cb-32be-1c91-c0ba-d50b4ca5e51b",
    "detail-type": "Support Case Update",
    "source": "aws.support",
    "account": "111122223333",
    "time": "2022-02-21T15:51:31Z",
    "region": "us-east-1",
    "resources": [],
    "detail": {
        "case-id": "case-111122223333-muen-2022-7118885805350839",
        "display-id": "1234563851",
        "communication-id": "ekko:us-east-1:12345678-268a-424b-be08-54613cab84d2",
        "event-name": "AddCommunicationToCase",
        "origin": "AWS"
    }
}
```

**Example 支援案例更新事件範例：支援案例已解決**  <a name="event-detail-support-case-update.example-3"></a>

```
{
    "version": "0",
    "id": "1aa4458d-556f-732e-ddc1-4a5b2fbd14a5",
    "detail-type": "Support Case Update",
    "source": "aws.support",
    "account": "111122223333",
    "time": "2022-02-21T15:51:31Z",
    "region": "us-east-1",
    "resources": [],
    "detail": {
        "case-id": "case-111122223333-muen-2022-7118885805350839",
        "display-id": "1234563851",
        "communication-id": "",
        "event-name": "ResolveCase",
        "origin": ""
    }
}
```

**Example 支援案例更新事件範例：已重新開啟支援案例**  <a name="event-detail-support-case-update.example-4"></a>

```
{
    "version": "0",
    "id": "3bb9d8fe-6089-ad27-9508-804209b233ad",
    "detail-type": "Support Case Update",
    "source": "aws.support",
    "account": "111122223333",
    "time": "2022-02-21T15:47:19Z",
    "region": "us-east-1",
    "resources": [],
    "detail": {
        "case-id": "case-111122223333-muen-2021-27f40618fe0303ea",
        "display-id": "1234563851",
        "communication-id": "",
        "event-name": "ReopenCase",
        "origin": ""
    }
}
```