

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

# 使用 Amazon EventBridge 比對 AWS Secrets Manager 事件
<a name="monitoring-eventbridge"></a>

在 Amazon EventBridge 中，您可以比對 CloudTrail 日誌項目中的 Secrets Manager 事件。您可以設定尋找這些事件的 EventBridge 規則，然後將新產生的事件傳送至目標以採取動作。如需 Secrets Manager 記錄的 CloudTrail 項目清單，請參閱 [CloudTrail 事件](cloudtrail_log_entries.md)。如需設定 EventBridge 的說明，請參閱《EventBridge 使用者指南》**中的 [EventBridge 入門](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-get-started.html)。

## 比對指定機密的所有變更
<a name="monitoring-eventbridge_examples-all-changes"></a>

**注意**  
由於[部分 Secrets Manager 事件](cloudtrail_log_entries.md)會以不同的大小寫傳回機密的 ARN，因此在比對多個動作的事件模式中，若要透過 ARN 指定機密，您可能需要同時包含金鑰 `arn` 和 `aRN`。如需詳細資訊，請參閱 [AWS re:Post](https://repost.aws/knowledge-center/secrets-manager-arn)。

下列範例顯示用於比對機密變更之日誌項目的 EventBridge 事件模式。

```
{
    "source": ["aws.secretsmanager"],
    "detail-type": ["AWS API Call via CloudTrail"],
    "detail": {
        "eventSource": ["secretsmanager.amazonaws.com"],
        "eventName": ["DeleteResourcePolicy", "PutResourcePolicy", "RotateSecret", "TagResource", "UntagResource", "UpdateSecret"],
        "responseElements": {
            "arn": ["arn:aws:secretsmanager:us-west-2:012345678901:secret:mySecret-a1b2c3"]
        }
    }
}
```

## 機密值輪換時比對事件
<a name="monitoring-eventbridge_examples-rotations"></a>

下列範例顯示用於比對從手動更新或自動輪換發生之機密值變更的 CloudTrail 日誌項目的 EventBridge 事件模式。由於其中一些事件來自 Secrets Manager 操作，一些由 Secrets Manager 服務產生，因此您必須包含兩者的 `detail-type`。

```
{
    "source": ["aws.secretsmanager"],
    "detail-type": [
        "AWS API Call via CloudTrail",
        "AWS Service Event via CloudTrail"
    ],
    "detail": {
        "eventSource": ["secretsmanager.amazonaws.com"],
        "eventName": ["PutSecretValue", "UpdateSecret", "RotationSucceeded"]
    }
}
```