

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

# 將 AWS DevOps 代理程式與 Amazon EventBridge 整合
<a name="configuring-capabilities-for-aws-devops-agent-integrating-devops-agent-into-event-driven-applications-using-amazon-eventbridge-index"></a>

您可以使用調查和緩解生命週期期間發生的事件，將 AWS DevOps 代理程式與您的事件驅動型應用程式整合。 AWS DevOps 代理程式會在調查或緩解狀態變更時將事件傳送至 Amazon EventBridge。然後，您可以建立 EventBridge 規則，根據這些事件採取動作。

例如，您可以建立執行下列動作的規則：
+ 當調查完成時，叫用 AWS Lambda 函數來處理調查結果。
+ 當調查失敗或逾時時傳送 Amazon SNS 通知。
+ 在建立新的調查時更新票證系統。
+ 在緩解動作完成時啟動 AWS Step Functions 工作流程。

## EventBridge 如何路由 AWS DevOps 代理程式事件
<a name="how-eventbridge-routes-aws-devops-agent-events"></a>

AWS DevOps Agent 會將事件傳送至 EventBridge 預設事件匯流排。然後EventBridge 會根據您建立的規則評估事件。當事件符合規則的事件模式時，EventBridge 會將事件傳送至指定的目標。

下圖顯示 EventBridge 如何路由 AWS DevOps 代理程式事件。

![Amazon EventBridge 會將事件從 AWS 來源透過規則路由到 AWS 服務等目標。](http://docs.aws.amazon.com/zh_tw/devopsagent/latest/userguide/images/eventbridge-integration-how-it-works.png)


1. 當調查或緩解生命週期狀態變更時，AWS DevOps 代理程式會將事件傳送至 EventBridge 預設事件匯流排。

1. EventBridge 會根據您建立的規則評估事件。

1. 如果事件符合規則的事件模式，EventBridge 會將事件傳送至規則中指定的目標。

## AWS DevOps 代理程式事件
<a name="aws-devops-agent-events"></a>

AWS DevOps Agent 會將下列事件傳送至 EventBridge。所有事件都使用來源 `aws.aidevops`。

### 支援的調查事件
<a name="supported-investigation-events"></a>


| 詳細資訊類型 | 說明 | 
| --- | --- | 
| Investigation Created | 已在客服人員空間中建立調查。 | 
| Investigation Priority Updated | 調查的優先順序已變更。 | 
| Investigation In Progress | 調查已開始主動分析。 | 
| Investigation Completed | 調查結果已成功完成調查。 | 
| Investigation Failed | 調查發生錯誤，無法完成。 | 
| Investigation Timed Out | 調查超過允許的持續時間上限。 | 
| Investigation Cancelled | 調查在完成之前已取消。 | 
| Investigation Pending Triage | 在主動分析開始之前，調查正在等待分類。 | 
| Investigation Linked | 調查已連結至相關事件或票證。 | 
| Investigation Skipped | 調查已略過，因為它符合技能中定義的略過條件。 | 

### 支援的緩解事件
<a name="supported-mitigation-events"></a>


| 詳細資訊類型 | 說明 | 
| --- | --- | 
| Mitigation In Progress | 已啟動緩解動作。 | 
| Mitigation Completed | 已成功完成緩解動作。 | 
| Mitigation Failed | 緩解動作發生錯誤，無法完成。 | 
| Mitigation Timed Out | 緩解動作超過允許的持續時間上限。 | 
| Mitigation Cancelled | 緩解動作已在完成之前取消。 | 

如需詳細的欄位描述和範例事件，請參閱 [AWS DevOps Agent 事件詳細資訊參考](integrating-devops-agent-into-event-driven-applications-using-amazon-eventbridge-devops-agent-events-detail-reference.md)。

## 建立符合 AWS DevOps 代理程式事件的事件模式
<a name="creating-event-patterns-that-match-aws-devops-agent-events"></a>

EventBridge 規則使用事件模式來選取事件並將其路由至目標。事件模式符合其處理的事件結構。您可以建立事件模式，根據事件欄位篩選 AWS DevOps 代理程式事件。

下列範例顯示常見使用案例的事件模式。

**比對 all AWS DevOps 代理程式事件**

下列事件模式符合來自 AWS DevOps Agent 的所有事件。

```
{
  "source": ["aws.aidevops"]
}
```

**僅比對調查事件**

下列事件模式使用字首比對來僅選取調查生命週期事件。

```
{
  "source": ["aws.aidevops"],
  "detail-type": [{"prefix": "Investigation"}]
}
```

**僅比對完成和失敗事件**

下列事件模式符合已完成或失敗的調查和緩解措施的事件。

```
{
  "source": ["aws.aidevops"],
  "detail-type": [
    "Investigation Completed",
    "Investigation Failed",
    "Mitigation Completed",
    "Mitigation Failed"
  ]
}
```

**比對特定客服人員空間的事件**

下列事件模式符合來自特定客服人員空間的事件。

```
{
  "source": ["aws.aidevops"],
  "detail": {
    "metadata": {
      "agent_space_id": ["your-agent-space-id"]
    }
  }
}
```

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

## Amazon EventBridge 許可
<a name="amazon-eventbridge-permissions"></a>

AWS DevOps Agent 不需要額外的許可，即可將事件交付至 EventBridge。事件會自動傳送至預設事件匯流排。

根據您為 EventBridge 規則設定的目標，您可能需要新增特定許可。如需目標所需許可的詳細資訊，請參閱《[Amazon EventBridge 使用者指南》中的使用 Amazon EventBridge 的資源型政策](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-use-resource-based.html)。 * EventBridge *

## 額外 EventBridge 資源
<a name="additional-eventbridge-resources"></a>

如需 EventBridge 概念和組態的詳細資訊，請參閱《*Amazon EventBridge 使用者指南*》中的下列主題：
+ [EventBridge 事件匯流排](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-bus.html)
+ [EventBridge 事件](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-events.html)
+ [EventBridge 事件模式](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html)
+ [EventBridge 規則](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-rules.html)
+ [EventBridge 目標](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-targets.html)