View a markdown version of this page

匹配 AWS Secrets Manager 与亚马逊举办的活动 EventBridge - AWS Secrets Manager

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

匹配 AWS Secrets Manager 与亚马逊举办的活动 EventBridge

在亚马逊中 EventBridge,您可以匹配 CloudTrail 日志条目中的 Secrets Manager 事件。您可以配置 EventBridge 规则来查找这些事件,然后将新生成的事件发送到目标以采取行动。有关 Secrets Manager 记录的 CloudTrail 条目列表,请参阅CloudTrail 条目。有关设置说明 EventBridge,请参阅《EventBridge 用户指南》 EventBridge中的 “入门”。

注意

本主题介绍 EventBridge 来自 CloudTrail 日志条目的匹配的 Secrets Manager 事件。Secrets Manager 还会直接向 EventBridge其发布原生Secret Label Updated事件,例如不需要的事件 CloudTrail。有关原生事件的更多信息,请参阅秘密事件通知

将所有更改与指定密钥匹配

注意

由于某些 Secrets Manager 事件返回的密钥 ARN 大小写不同,所以在匹配多个操作的事件模式中,您可能需要同时包含密钥 arnaRN 才能通过 ARN 指定密钥。有关更多信息,请参阅 AWS re:Post

以下示例显示了一种 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"] } } }

在轮换密钥值时匹配事件

要检测密钥的活动值何时发生变化,我们建议您将本机Secret Label Updated事件与AWSCURRENT暂存标签相匹配。每当活动密钥值发生变化时,无论是手动更新还是自动轮换,Secrets Manager 都会将AWSCURRENT标签移动到新版本。默认情况下,所有密钥都启用此事件,并路由到默认 EventBridge 事件总线。要使用它,您需要添加与之匹配的事件模式,如以下示例所示。

{ "source": ["aws.secretsmanager"], "detail-type": ["Secret Label Updated"], "detail": { "labelUpdated": ["AWSCURRENT"] } }

有关该Secret Label Updated事件的更多信息,请参阅秘密事件通知

或者,您可以匹配更改机密值的操作的 CloudTrail 日志条目。其中一些事件来自 Secrets Manager 的操作,有些则由 Secrets Manager 服务生成。两者都必须包含。detail-type以下示例显示了与这些 CloudTrail 日志条目匹配 EventBridge 的事件模式。

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