# hkb-alert-masteradmin-writes

Fires on: Direct write API calls (CLI or console) by an HKB-MasterAdmin session in us-east-1 and global services. Calls made by services on its behalf (invokedBy set, e.g. CloudFormation) are excluded. Replaces the GetRoleCredentials rule, which EventBridge never receives (read-only IdentityCenterUser service event; verified 2026-10-05).

Run the [common pre-checks](/wiki/runbooks/#common-pre-checks) first.

## Symptoms
An email from `hkb master alert`: `HKB-MasterAdmin direct WRITE call` naming the service and API. A person's admin session changed something directly, outside CloudFormation.

## Pre-checks
1. Some manual steps are direct writes by design (the [rebuild guide](/wiki/rebuild/) lists each one, with its identity). Does the call match a step being run?
2. Changes through CloudFormation are excluded from this rule (`invokedBy` set), so this email means the call came from the CLI or the console.

## Resolution
- **A listed manual step:** nothing to do; the step's check proves it.
- **Not listed:** find the call in CloudTrail, work out what it changed, and put it back from the repository. If the session itself wasn't planned, follow the console sign-in runbook above.

## Post-checks
The verifier passes, and INV-11 shows the management, Shared Services and Security stacks and the StackSets matching the repository.

## Rollback
Undo the direct change with the opposite call, or update the owning stack from the repository.

## Alert details

| Property | Value |
| --- | --- |
| Runs in | the management account, us-east-1 |
| Email | From `hkb master alert`: `HKB-MasterAdmin direct WRITE call in the management account at <time>: <svc> <api> from <ip>.` |
| Source | `security/hkb-security-master-alerts.yaml`, resource `MasterAdminWritesRule` |

The event pattern, as deployed:

```yaml
EventPattern:
  detail-type: [AWS API Call via CloudTrail]
  detail:
    readOnly: [false]
    userIdentity:
      arn:
        - wildcard: "*assumed-role/AWSReservedSSO_HKB-MasterAdmin_*"
      invokedBy:
        - exists: false
```
