

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 授权使用 EventBridge 客户管理的密钥
<a name="eb-encryption-key-policy"></a>

如果您在账户中使用客户托管密钥来保护您的 EventBridge 资源，则该 KMS 密钥的策略必须 EventBridge 允许您代表您使用该密钥。您可以在[密钥策略](https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html)中提供这些权限。

EventBridge 不需要额外的授权即可使用默认设置 AWS 拥有的密钥 来保护您 AWS 账户中的 EventBridge 资源。

EventBridge 需要以下权限才能使用客户托管密钥：
+ [https://docs.aws.amazon.com/kms/latest/APIReference/API_DescribeKey.html](https://docs.aws.amazon.com/kms/latest/APIReference/API_DescribeKey.html)

  EventBridge 需要此权限才能检索所提供的密钥 ID 的 KMS 密钥 ARN，并验证密钥是否对称。
+ [https://docs.aws.amazon.com/kms/latest/APIReference/API_GenerateDataKey.html](https://docs.aws.amazon.com/kms/latest/APIReference/API_GenerateDataKey.html)

  EventBridge 需要此权限才能生成数据密钥作为数据的加密密钥。
+ [https://docs.aws.amazon.com/kms/latest/APIReference/API_Decrypt.html](https://docs.aws.amazon.com/kms/latest/APIReference/API_Decrypt.html)

  EventBridge 需要此权限才能解密与加密数据一起加密并存储的数据密钥。

  EventBridge 将其用于事件模式匹配；用户永远无法访问数据。

## 使用客户管理的密钥进行 EventBridge 加密时的安全性
<a name="eb-encryption-event-bus-confused-deputy"></a>

作为安全最佳实践，请在密钥策略中添加`aws:SourceArn``aws:sourceAccount`、或`kms:EncryptionContext:aws:events:event-bus:arn`条件 AWS KMS 密钥。IAM 全局条件密钥有助于确保仅对指定的总线或账户 EventBridge 使用 KMS 密钥。

以下示例演示了如何在事件总线的 IAM 策略中遵循此最佳实践：

```
{
      "Sid": "Allow the use of key",
      "Effect": "Allow",
      "Principal": {
        "Service": "events.amazonaws.com"
      },
      "Action": [
        "kms:GenerateDataKey",
        "kms:Decrypt"
      ],
      "Resource": "*",
      "Condition" : {
        "StringEquals": {
          "aws:SourceAccount": "arn:aws:events:region:account-id",
          "aws:SourceArn": "arn:aws:events:region:account-id:event-bus/event-bus-name",
          "kms:EncryptionContext:aws:events:event-bus:arn": "arn:aws:events:region:account-id:event-bus/event-bus-arn"
        }
      }
```