Skip to content

the EventBridge Rule can not detect event pattern for ScheduleKeyDeletion

0

hi. I added a service control policy to deny any user to delete the kms key. so all account (Except management) cannot schedule a key deletion. actually, when a user tries to delete the key, an error appeared and an event added in CloudTrail like this:

...
 "eventSource": "kms.amazonaws.com",
"eventName": "ScheduleKeyDeletion",
 "errorCode": "AccessDenied",
....

so my question is, I created an event bridge rule to detect the event pattern for ScheduleKeyDeletion but the rule can not detect the event. can it be for scp? any idea? thanks everyone!

1 Answer
1
Accepted Answer

KMS doesn't send denied key deletion scheduling events directly to EventBridge but to CloudTrail. In order for EventBridge to receive them, you must have a custom trail configured in CloudTrail for the region where you want EventBridge to react to the events, or all regions, and set to record management events. Without a trail configured or if only data events are included, you can see KMS key deletions or other management events in the CloudTrail console, but they won't be delivered to EventBridge.

When you have a trail configured, the event pattern to catch key deletions should look like this:

{
  "source": ["aws.kms"],
  "detail-type": ["AWS API Call via CloudTrail"],
  "detail": {
    "eventSource": ["kms.amazonaws.com"],
    "eventName": ["ScheduleKeyDeletion"]
  }
}

The events will only be delivered to EventBridge in the account and region where the kms:ScheduleKeyDeletion API was called. For example, the management account of the organisation won't receive these events from member accounts, so the rule will have to be configured in each member account and region separately.

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

  • thanks. so I need to create new trail for record management event in member account.am I right? can I do this as a member or only management account is able to do this?

  • @gh02 It suffices for there to be (at least) one CloudTrail trail in the account and region where you want to catch the events. In an AWS Organization, you'd typically have an organisation-wide trail for all your regions set to record at least all management events. If you have that, you don't need to create an additional trail. You can simply create an EventBridge rule with the pattern above.

  • yeah . so since I dont have it in management account, I need to create one trail in all account and region. am I right?

  • Yes. If you haven't got an organisation trail created, which would be strongly recommended (https://docs.aws.amazon.com/awscloudtrail/latest/userguide/creating-trail-organization.html), you have to create a trail in each member account separately. The trail can be region-specific, but you can also create a single multi-region trail to cover all regions in the account. You can see both account-local and organisation trails in the CloudTrail management console under "trails" in each member account.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.