

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

# 使用 AWS KMS 金鑰加密 EventBridge 事件匯流排
<a name="eb-encryption-event-bus-cmkey"></a>

您可以指定 EventBridge 使用 AWS KMS 來加密儲存在事件匯流排上的資料，而不是使用預設 AWS 擁有的金鑰 的 。您可以在建立或更新事件匯流排時指定客戶受管金鑰。您也可以更新預設事件匯流排，以使用客戶受管金鑰進行加密。如需詳細資訊，請參閱[KMS 金鑰選項](eb-encryption-at-rest-key-options.md)。

 當您為事件匯流排指定客戶受管金鑰時，EventBridge 會使用該金鑰來加密下列項目：
+ 儲存在事件匯流排上的[自訂](eb-putevents.md)和[合作夥伴](eb-saas.md)事件。

  來自 AWS 服務的事件會使用 加密 AWS 擁有的金鑰。

  EventBridge 不會加密事件中繼資料。如需事件中繼資料的詳細資訊，請參閱 [AWS 事件參考中的服務事件中繼資料](https://docs.aws.amazon.com/eventbridge/latest/ref/events-structure.html)。 **
+ 對於匯流排上的每個[規則](eb-rules.md)：
  + 規則[事件模式](eb-event-patterns.md)。
  + [目標](eb-targets.md)資訊，包括目標輸入、[輸入轉換器](eb-transform-target-input.md)和[組態參數](eb-create-rule-wizard.md#eb-create-rule-target)。
+ 如果啟用[事件匯流排記錄](eb-event-bus-logs.md)，日誌記錄的 `detail`和 `error`區段。

如果您為事件匯流排指定客戶受管金鑰，您可以選擇為事件匯流排指定無效字母佇列 (DLQ)。然後EventBridge 會將產生加密或解密錯誤的任何自訂或合作夥伴事件交付至該 DLQ。如需詳細資訊，請參閱[加密事件DLQs ](eb-encryption-event-bus-dlq.md)。

**注意**  
我們強烈建議為事件匯流排指定 DLQ，以確保在發生加密或解密錯誤時保留事件。

您也可以指定使用客戶受管金鑰來加密事件匯流排封存。如需詳細資訊，請參閱[加密封存](encryption-archives.md)。

**注意**  
使用客戶受管金鑰加密的事件匯流排不支援結構描述探索。若要在事件匯流排上啟用結構描述探索，請選擇使用 AWS 擁有的金鑰。如需詳細資訊，請參閱[KMS 金鑰選項](eb-encryption-at-rest-key-options.md)。

## 事件匯流排加密內容
<a name="eb-encryption-at-rest-context-bus"></a>

[加密內容](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#encrypt_context)是一組金鑰/值對，其中包含任意非私密資料。在加密資料的請求中包含加密內容時， AWS KMS 會以密碼編譯方式將加密內容繫結至加密的資料。若要解密資料，您必須傳遞相同的加密內容。

您也可以使用加密內容做為政策和授權的條件。

如果您使用客戶受管金鑰來保護 EventBridge 資源，您可以使用加密內容來識別稽核記錄和日誌 KMS key 中 的使用。它也會以純文字顯示在日誌中，例如 [AWS CloudTrail](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-user-guide.html) 和 [Amazon CloudWatch Logs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html)。

對於事件匯流排，EventBridge 在所有 AWS KMS 密碼編譯操作中使用相同的加密內容。內容包含單一索引鍵/值對，其中包含事件匯流排 ARN。

```
"encryptionContext": {
    "kms:EncryptionContext:aws:events:event-bus:arn": "{{event-bus-arn}}"
}
```

## AWS KMS 事件匯流排的金鑰政策
<a name="eb-encryption-key-policy-bus"></a>

下列範例金鑰政策提供事件匯流排的必要許可：
+ `kms:DescribeKey`
+ `kms:GenerateDataKey`
+ `kms:Decrypt`

作為安全最佳實務，我們建議您在金鑰政策中包含條件金鑰，以協助確保 EventBridge 僅針對指定的資源或帳戶使用 KMS 金鑰。如需詳細資訊，請參閱[安全考量](eb-encryption-key-policy.md#eb-encryption-event-bus-confused-deputy)。

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Sid": "AllowEventBridgeToValidateKeyPermission",
      "Effect": "Allow",
      "Principal": {
      "Service": "events.amazonaws.com"
       },
      "Action": [
        "kms:DescribeKey"
        ],
      "Resource": "*"
    },
  {
    "Sid": "AllowEventBridgeToEncryptEvents",
    "Effect": "Allow",
    "Principal": {
      "Service": "events.amazonaws.com"
    },
    "Action": [
      "kms:GenerateDataKey",
      "kms:Decrypt"
    ],
    "Resource": "*",
    "Condition": {
      "StringEquals": {
          "kms:EncryptionContext:aws:events:event-bus:arn": "arn:aws:events:us-east-1:123456789012:event-bus/event-bus-arn",
          "aws:SourceArn": "arn:aws:events:us-east-1:123456789012:event-bus/event-bus-name"
        }
      } 
    }
  ] }
```

------

## AWS KMS 事件匯流排動作的金鑰許可
<a name="eb-encryption-key-permissions-bus"></a>

若要建立或更新使用客戶受管金鑰加密的事件匯流排，您必須具有指定客戶受管金鑰的下列許可：
+ `kms:GenerateDataKeyWithoutPlaintext`
+ `kms:Decrypt`
+ `kms:Encrypt`
+ `kms:ReEncryptFrom`
+ `kms:ReEncryptTo`
+ `kms:DescribeKey`

此外，若要在使用客戶受管金鑰加密的事件匯流排上執行特定事件匯流排動作，您必須擁有指定客戶受管金鑰的`kms:Decrypt`許可。這些動作包括：
+ `[DescribeRule](https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_DescribeRule.html)`
+ `[DisableRule](https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_DisableRule.html)`
+ `[EnableRule](https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_EnableRule.html)`
+ `[ListRules](https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_ListRules.html)`
+ `[ListTargetsByRule](https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_ListTargetsByRule.html)`
+ `[PutRule](https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutRule.html)`
+ `[ListRuleNamesByTarget](https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_ListRuleNamesByTarget.html)`
+ `[PutTargets](https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutTargets.html)`