KMS Key Rotation Operator
What this skill does
Executes KMS key rotation operations correctly and safely. Runs
deterministic pre-checks before any state-changing CLI (key Enabled,
not PendingDeletion, symmetric SYMMETRIC_DEFAULT usage, Multi-Region
primary not replica, EnableKeyRotation permission in the key policy,
not a custom key store with external rotation), executes the
enable-key-rotation / disable-key-rotation CLI behind a CONFIRM
gate, and verifies the result by confirming
get-key-rotation-status returns Enabled: true and CloudTrail shows
the EnableKeyRotation event. Every enable-rotation produces a
cryptographic-material lifecycle note (old backing material retained
for decrypt of existing ciphertext; new material encrypts all new
operations transparently). Every asymmetric/HMAC key plan routes to
manual rotation (create new key, update callers, re-encrypt) since
automatic rotation is not supported.
Quick navigation
| Section |
What it covers |
When to read it |
| § Quick reference |
Verdict thresholds (BLOCKED/READY/COMPLETED) + pre-check priority |
Before any operation |
| § Mindset |
Why rotation is transparent, the asymmetric-gap, the confirm gate |
Understanding the safety model |
| § Pre-flight |
Key metadata gate — Enabled state, PendingDeletion, Multi-Region, custom key store |
Before executing any CLI |
| § Process |
Per-operation planning: enable, verify, disable, plan-manual, diagnose |
When choosing which operation to run |
| § Output format |
Structured OPERATION/VERDICT/PRE_CHECKS/STEPS/POST_VERIFY template |
Formatting the response |
| § Anti-Patterns |
NEVER list — common mistakes that break encryption or strand data |
Review before risky operations |
| § Pre-flight safety |
Capture pre-state, CloudTrail trail verification, key policy check |
Defense-in-depth |
Quick reference — verdict thresholds
| Verdict |
Trigger condition |
Action |
BLOCKED |
One or more pre-checks failed (key Disabled, key PendingDeletion, asymmetric/HMAC usage with auto-rotation requested, replica key with auto-rotation requested, missing EnableKeyRotation permission, custom key store with external rotation) |
List failures, do NOT execute |
READY |
All pre-checks passed; awaiting CONFIRM gate |
Emit exact CLI sequence, wait for operator yes |
COMPLETED |
Rotation enable/disable finished and post-verification passed (get-key-rotation-status matches intent, CloudTrail event present, key policy unchanged, applications using key ARN still work) |
Emit verification results, monitoring plan |
Priority order for pre-checks (apply in this sequence, all must pass
for READY):
- Key reachability — key exists (
describe-key does not return
NotFoundException), Enabled true, KeyState: Enabled.
- No deletion pending —
KeyState is NOT PendingDeletion (no
rotation during the deletion window).
- Key supports automatic rotation —
KeySpec is
SYMMETRIC_DEFAULT (or AES_256 for multi-Region primary) AND
KeyUsage: ENCRYPT_DECRYPT AND Origin: AWS_KMS. Asymmetric,
HMAC, and external-key-material keys do NOT support automatic
rotation.
- Multi-Region primary — for Multi-Region keys, rotation is
controlled by the primary key. A replica key
(
MultiRegionConfiguration.PrimaryArmy != self) inherits the
primary's rotation status; EnableKeyRotation on a replica fails.
- Key policy permission — the calling identity must have
kms:EnableKeyRotation (or kms:DisableKeyRotation) on the key
ARN. The key's own resource-based policy must allow the caller, or
the caller's identity-based policy must grant it. Cross-account
callers need both sides.
- Custom key store check — for
Origin: AWS_CLOUDHSM, rotation
is supported (KMS rotates the backing key in the CloudHSM cluster),
but the cluster must be ACTIVE. For Origin: EXTERNAL, rotation
is NOT supported (you manage the key material externally).
- Schedule intent clarity —
enable-key-rotation accepts an
optional --rotation-period-in-days (7-365, default 365). Confirm
the intended cadence before enabling.
Cost/time baselines (2026):
- Customer-managed CMK: $1.00/key/month (regardless of rotation).
- Automatic rotation: no additional per-rotation fee. The CMK keeps
its key ID and ARN; KMS retains old backing material for decrypt.
- Asymmetric keys (RSA, ECC): $1.00/key/month; do NOT support
automatic rotation. Manual rotation = create new key + update
callers + optional re-encrypt.
- HMAC keys: $1.00/key/month; do NOT support automatic rotation.
- Multi-Region keys: $1.00 per primary + $1.00 per replica.
- CloudTrail
EnableKeyRotation / DisableKeyRotation events: free
(management events).
- Re-encryption cost (manual rotation):
$0.03 per 10,000
Encrypt/Decrypt requests. Re-encrypting a large S3 bucket or
DynamoDB table is the dominant cost, not KMS itself.
Mindset
One-line takeaway: automatic KMS key rotation is transparent to
applications — the key ID and ARN do not change, and old backing
material is retained so existing ciphertext remains decryptable.
Driven by three KMS realities:
Rotation swaps backing material, not the key. A KMS key is a
logical construct (key ID + ARN + policy) backed by cryptographic
material. Automatic rotation creates new backing material under the
same key ID. All new Encrypt operations use the new material; all
Decrypt operations on existing ciphertext use the material that
originally encrypted it (KMS tracks which material produced each
ciphertext via the encryption context). Applications see no change.
Asymmetric and HMAC keys are the rotation blind spot. Automatic
rotation is supported ONLY on symmetric ENCRYPT_DECRYPT keys with
Origin: AWS_KMS (and CloudHSM-backed symmetric keys). RSA, ECDSA,
HMAC, and external-material keys do NOT support automatic rotation.
For these, you must rotate manually: create a new key, update all
callers to use the new key ARN, and optionally re-encrypt old data.
This is a significant operational gap — auditors asking "are all
keys rotating annually?" need to be told that asymmetric keys are
manually rotated.
A Multi-Region replica key's rotation is set on the primary.
Calling EnableKeyRotation on a replica returns
InvalidOperationException. Multi-Region replica keys share the
same cryptographic material as the primary — when the primary's
backing material rotates, replicas receive the new material
automatically. Verify rotation on the primary's
get-key-rotation-status.
Pre-flight: key metadata gate
Run before classification. Misclassifying these produces wrong plans.
Pagination + live-account pre-flight commands moved verbatim to
references/diagnostic-commands.md (load on demand).
Malformed input: if the input JSON is invalid or missing required
fields, emit VERDICT: ERROR with REASON: Key configuration is not valid JSON or is missing required fields — cannot plan. and
REMEDIATION: Re-fetch with aws kms describe-key --key-id <id> --output json and re-plan.
| Key attribute |
Effect on operation |
KeyState: PendingDeletion + DeletionDate set |
BLOCKED — key in deletion window (7-30 days). Cancel deletion (schedule-key-deletion with --pending-window-in-days 0 is not supported; you must wait or use cancel-key-deletion to restore). |
KeyState: Disabled |
BLOCKED — key disabled. EnableKeyRotation requires Enabled: true. Call enable-key first. |
KeyUsage: SIGN_VERIFY (asymmetric) |
BLOCKED for automatic rotation. Manual rotation required. |
KeyUsage: GENERATE_VERIFY_MAC (HMAC) |
BLOCKED for automatic rotation. Manual rotation required. |
KeySpec: RSA_2048 / ECC_NIST_P256 etc. |
BLOCKED for automatic rotation. Manual rotation required. |
Origin: EXTERNAL (BYOK / imported material) |
BLOCKED for automatic rotation. Re-import new material to rotate. |
Origin: AWS_CLOUDHSM |
Supported if the cluster is ACTIVE. KMS rotates the backing key in the CloudHSM. |
MultiRegionConfiguration.MultiRegionKeyType: REPLICA |
BLOCKED for EnableKeyRotation on the replica. Enable on the primary; replica inherits. |
MultiRegionConfiguration.MultiRegionKeyType: PRIMARY |
OK — rotation propagates to all replicas automatically. |
Key policy denies caller kms:EnableKeyRotation |
BLOCKED — add the permission to the policy (or call from a role that already has it). |
Enabled: false in get-key-rotation-status |
Not an error — rotation is currently disabled. The operation enable-rotation will enable it. |
Enabled: true in get-key-rotation-status |
If the operation is enable-rotation, no-op or update RotationPeriodInSeconds. If disable-rotation, plan the disable. |
Process — operation planning (apply in order)
Step 0: Expert knowledge — non-obvious KMS behaviors
Step-0 expert behaviors moved verbatim to references/advanced-patterns.md
(backing material, rotation period, aliases, grants, AWS-managed keys, more).
Step 1: Pre-check gate — BLOCKED if any check fails
Run ALL pre-checks for the chosen operation. If ANY fails, the verdict
is BLOCKED with the failed checks in PRE_CHECKS. Do NOT execute.
For ALL operations:
- Key exists (
describe-key does not return NotFoundException).
- Key is NOT
PendingDeletion (DeletionDate absent,
KeyState != PendingDeletion).
- Calling identity has
kms:GetKeyRotationStatus on the key (for
verify-rotation and diagnose-rotation).
For enable-rotation (enable-key-rotation --key-id):
4. KeyState: Enabled (not Disabled).
5. KeySpec: SYMMETRIC_DEFAULT (or AES variant).
6. KeyUsage: ENCRYPT_DECRYPT.
7. Origin: AWS_KMS OR Origin: AWS_CLOUDHSM (with cluster ACTIVE).
8. NOT a Multi-Region replica
(MultiRegionConfiguration.MultiRegionKeyType == PRIMARY or key is
single-region).
9. Calling identity has kms:EnableKeyRotation on the key ARN.
10. (Optional) --rotation-period-in-days is in [7, 365], if
specified.
For verify-rotation (read-only, no BLOCKED gate for state):
4. get-key-rotation-status returns Enabled and NextRotationDate.
5. CloudTrail shows an EnableKeyRotation event matching the key ARN
(within the last rotation period).
6. (Optional) NextRotationDate is within the expected window.
For disable-rotation (disable-key-rotation --key-id):
4. KeyState: Enabled.
5. Current get-key-rotation-status.Enabled: true (otherwise it is a
no-op).
6. Calling identity has kms:DisableKeyRotation on the key ARN.
7. (Advisory) Disabling rotation is rare and usually a compliance
violation. Confirm the operator has a documented reason.
For plan-manual-rotation (asymmetric / HMAC / external-material):
4. Key is asymmetric (KeyUsage: SIGN_VERIFY), HMAC
(GENERATE_VERIFY_MAC), or Origin: EXTERNAL.
5. Operator has kms:CreateKey permission (to create the new key).
6. List of all callers / aliases that reference the key — needed to
plan the cutover.
7. (Optional) The set of ciphertexts / signatures / MACs that need
re-encryption or re-signing (for compliance).
For diagnose-rotation (read-only):
4. Read get-key-rotation-status, CloudTrail events, and the
failure-mode table to identify why rotation cannot be enabled or
why it did not run.
Rotation failure-mode table (use during diagnose-rotation):
Rotation failure-mode table (API errors -> fixes) moved verbatim to
references/error-handling.md (load on demand).
Step 2: READY — emit operation plan
If all pre-checks pass, emit VERDICT: READY with the exact CLI
sequence and the CONFIRM gate. The plan includes:
- The exact AWS CLI command with all flags populated from the key
configuration.
- The expected
RotationPeriodInSeconds (365 days default, or the
specified value).
- The expected side-effects (rotation status flips to
Enabled,
NextRotationDate is set to ~365 days from now, key policy
unchanged, applications unaffected).
- The CONFIRM gate prompt.
- The verification step (
get-key-rotation-status + CloudTrail +
application spot-check).
Step 3: Execute behind CONFIRM gate
- MANDATORY CONFIRMATION GATE. Before any state-changing CLI
(
enable-key-rotation, disable-key-rotation, enable-key,
disable-key, schedule-key-deletion, cancel-key-deletion,
create-key, update-alias), emit:
CONFIRM: About to <operation> on KMS key <key-id> (account <account> region <region>). This will <consequence>. Proceed? (yes/no). Do NOT execute until the operator confirms.
- Capture pre-state for rollback:
aws kms describe-key --key-id <id> --output json > /tmp/<id>-describe-pre-$(date +%s).json AND
aws kms get-key-rotation-status --key-id <id> --output json > /tmp/<id>-rotation-pre-$(date +%s).json.
- Execute the CLI.
enable-key-rotation is synchronous — it returns
once the rotation schedule is set. The actual material rotation
happens at NextRotationDate.
- For manual rotations: the cutover (alias update or caller update)
is the state-changing step. Capture the alias pre-state.
Step 4: Post-verification — COMPLETED
After the CLI completes, run post-verification. ALL checks must pass
for COMPLETED.
get-key-rotation-status --key-id <id> — confirm Enabled: true
(or false for disable-rotation) and NextRotationDate is set
(or absent for disable).
- CloudTrail shows the
EnableKeyRotation (or DisableKeyRotation)
event with the key ARN and the caller's identity.
describe-key --key-id <id> — confirm KeyState: Enabled (the
key itself is unaffected by the rotation-status change).
get-key-policy --key-id <id> --policy-name default — confirm
the policy is unchanged (rotation does not modify policy).
list-grants --key-id <id> — confirm grants are unchanged.
- Spot-check: an application using the key ARN performs a test
Encrypt + Decrypt cycle successfully (or confirm via metrics
that no KMSKeyUnavailableException or AccessDeniedException
spike occurred).
If ANY verification fails, emit VERDICT: ERROR with the failure
details — do not claim COMPLETED. A failed verification typically
means the key policy was inadvertently modified or the key was
simultaneously disabled by another process.
Output format (per operation)
OPERATION: <enable-rotation | verify-rotation | disable-rotation | plan-manual-rotation | diagnose-rotation>
VERDICT: READY | BLOCKED | COMPLETED
TARGET: <key-id> (alias: <alias-or-"none">, account <account>, region <region>)
PRE_CHECKS:
- [PASS] <check description>
- [FAIL] <check description> — <reason>
STEPS:
1. <CLI command with flags populated>
2. <wait / monitoring command>
3. <next step>
POST_VERIFY:
- [PASS] <verification description>
- [FAIL] <verification description> — <reason>
NOTES: <rotation period, material lifecycle, monitoring, caveats>
Worked example — enable-rotation (symmetric CMK)
OPERATION: enable-rotation
VERDICT: READY
TARGET: arn:aws:kms:us-east-1:111111111111:key/abcd1234-... (alias:
alias/prod-app-encryption-key, account 111111111111, region
us-east-1)
PRE_CHECKS:
- [PASS] Key exists, KeyState: Enabled
- [PASS] Not PendingDeletion (DeletionDate absent)
- [PASS] KeySpec: SYMMETRIC_DEFAULT, KeyUsage: ENCRYPT_DECRYPT
- [PASS] Origin: AWS_KMS (supports automatic rotation)
- [PASS] Single-region key (not a Multi-Region replica)
- [PASS] Calling role has kms:EnableKeyRotation via key policy
statement allowing arn:aws:iam::111111111111:role/SecurityAdmin
- [PASS] RotationPeriodInSeconds: 365 (default — annual)
STEPS:
1. CONFIRM: About to enable automatic backing-key rotation on KMS
key alias/prod-app-encryption-key
(arn:aws:kms:us-east-1:111111111111:key/abcd1234-...) in account
111111111111 region us-east-1. Rotation period: 365 days. The key
ID, ARN, policy, grants, and aliases are unchanged. Existing
ciphertext remains decryptable. New Encrypt operations use the
new backing material after the first rotation. Proceed? (yes/no)
2. aws kms enable-key-rotation \
--key-id arn:aws:kms:us-east-1:111111111111:key/abcd1234-...
3. (Optional) Verify immediately:
aws kms get-key-rotation-status \
--key-id arn:aws:kms:us-east-1:111111111111:key/abcd1234-...
POST_VERIFY:
- (pending execution)
NOTES:
- The first rotation will occur within 24 hours of NextRotationDate
(approximately 365 days from enablement). KMS performs the
material swap; no application action is needed.
- Old backing material is retained indefinitely (until the key is
deleted). Existing ciphertext encrypted with old material remains
decryptable — no re-encryption required.
- CloudTrail will log the EnableKeyRotation event immediately. The
actual material rotation does NOT produce a separate CloudTrail
event; verify via NextRotationDate advancing.
- For compliance evidence, capture quarterly:
aws kms get-key-rotation-status --key-id <id>
and store the output with NextRotationDate.
Worked example — plan-manual-rotation (asymmetric RSA key)
Full plan-manual-rotation worked example moved verbatim to
references/worked-examples.md (load on demand).
Worked example — diagnose-rotation (BLOCKED with remediation)
Full diagnose-rotation worked example moved verbatim to
references/worked-examples.md (load on demand).
Anti-Patterns — NEVER
NEVER call enable-key-rotation on an asymmetric, HMAC, or
external-material key without first confirming it is a symmetric
AWS_KMS-origin key. The API returns InvalidOperationException;
the operator should plan a manual rotation instead.
NEVER call enable-key-rotation on a Multi-Region replica key. The
API returns InvalidOperationException. Enable rotation on the
primary; the replica inherits the status.
NEVER disable or delete an old key immediately after a manual
rotation. Existing ciphertext, signatures, or MACs produced with the
old key require the old key to be Enabled for decrypt / verify.
Disable only after confirming all artifacts have been re-encrypted /
re-signed or are no longer needed (typically 90+ days).
NEVER assume get-key-rotation-status.Enabled: true means a
rotation has occurred. It means rotation is SCHEDULED. The actual
material swap happens at NextRotationDate. For proof that a
rotation ran, compare NextRotationDate advancing over time or
inspect the key's internal material versions (KMS does not expose
material IDs publicly — NextRotationDate advancing is the
observable signal).
NEVER assume AWS-managed keys (aws/s3, aws/rds, etc.) rotate
annually. They rotate approximately every 3 years on an AWS-managed
schedule. You CANNOT enable, disable, or configure rotation on
AWS-managed keys. For annual rotation compliance, use customer-
managed keys.
NEVER modify the key policy as part of a rotation operation. The
policy is independent of the backing material. A policy change
during rotation creates confusion about which change caused any
subsequent access issue.
NEVER assume RotationPeriodInSeconds is fixed at 365 days. It is
configurable (7-365 days, default 365). Always read the current
value from get-key-rotation-status before planning.
NEVER confuse enable-key-rotation with rotate-key-on-demand
(2024+ feature for immediate material rotation on symmetric keys).
enable-key-rotation schedules recurring rotation;
rotate-key-on-demand performs an immediate material swap. Use
on-demand for incident response (suspected key compromise); use
scheduled for routine cryptographic agility.
NEVER call schedule-key-deletion to "force a rotation." Deletion
is irreversible within the 7-30 day window; cancel-key-deletion
restores the key but cancels its rotation schedule. Use
rotate-key-on-demand for an immediate rotation instead.
NEVER hard-code a key ARN in application configuration if you can
use an alias. Aliases make manual rotation a one-line update-alias
cutover; ARNs require updating every caller.
NEVER assume CloudTrail logs the actual material rotation. CloudTrail
logs EnableKeyRotation and DisableKeyRotation (management
events). The material swap itself is an internal KMS operation with
no separate CloudTrail event. Use NextRotationDate advancing as
the observable signal.
NEVER enable rotation on a key whose CloudHSM cluster is
DEGRADED or DISCONNECTED. The enable-key-rotation API may
succeed but the actual rotation will fail until the cluster is
ACTIVE. Verify cluster state first.
NEVER re-create grants after an automatic rotation. Grants are per-
key-ID and survive rotation. Re-creating grants can create
conflicting permissions and is unnecessary.
NEVER call disable-key-rotation without a documented compliance
exception. Disabling rotation is almost always a policy violation.
If the goal is to "pause" rotation temporarily, leave rotation
enabled and address the underlying concern instead.
NEVER auto-execute a state-changing KMS CLI without the CONFIRM
gate. Rotation operations are reversible, but disabling a key or
scheduling deletion during a "rotation" workflow can cause
immediate application outages.
Pre-flight safety checks (run before any remediation CLI)
Pre-flight safety checks moved verbatim to
references/diagnostic-commands.md (load on demand).
Recent AWS features (2024-2026)
Recent-feature details moved verbatim to
references/advanced-patterns.md (load on demand).
References (load on demand)
references/worked-examples.md — secondary worked examples: plan-manual-rotation (asymmetric RSA), diagnose-rotation (BLOCKED replica key).
references/advanced-patterns.md — Step-0 expert KMS rotation behaviors, recent AWS features 2024-2026.
references/error-handling.md — rotation failure-mode table (symptom / root cause / fix).
references/diagnostic-commands.md — sweep pagination, live-account pre-flight command listing, pre-flight safety checks.
references/key-type-and-rotation-matrix.md — key type rotation support matrix and procedures.
references/manual-rotation-procedures.md — manual rotation procedures (caller identification, cutover).
Domain
AWS CloudOps / KMS Key Rotation, Cryptographic Agility & Compliance.
AWS documentation
1---2name: kms-key-rotation-operator3description: Operates AWS KMS key rotation workflows end-to-end — key type classification (AWS-managed, customer-managed symmetric, asymmetric RSA/ECDSA, HMAC, Multi-Region primary/replica, custom key store / CloudHSM), automatic annual backing-key rotation enablement and verification, manual key rotation (create new CMK + re-encrypt), cryptographic material lifecycle (old material retained for decrypt, new encrypts transparently), and diagnostic loops (describe-key, get-key-rotation-status, CloudTrail EnableKeyRotation events, list-grants, key-policy diff). Runs deterministic pre-checks (key Enabled, key state not PendingDeletion, symmetric SYMMETRIC_DEFAULT usage, multi-Region primary not replica, EnableKeyRotation permission in key policy) behind a CONFIRM gate and emits a READY, BLOCKED, or COMPLETED verdict per rotation. Use when enabling automatic rotation, verifying rotation ran, planning a manual rotation, or diagnosing why rotation cannot be enabled.4license: Apache-2.05compatibility: Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf, Codex, Gemini). No AWS CLI required for offline plan classification. Live-account operations use aws kms describe-key, get-key-rotation- status, enable-key-rotation, disable-key-rotation, list-grants, get-key-policy, list-resource-tags, aws cloudtrail lookup-events (AWS CLI v2, SSO or key-based credentials).6metadata:7 source: https://skillmd.com/skills/jhkchan/kms-key-rotation-operator8 domain: aws-cloudops9 complexity: medium10 requires_llm: 'true'11 phase: '4'12 supports_pipeline: 'true'13 entry_point: 'false'14 family: Security15 task_type: operate16 skill_class: capability17 lifecycle_status: active18 verdict_shape: READY | BLOCKED | COMPLETED19 when_to_use: Enabling automatic backing-key rotation on a customer-managed KMS key, verifying a key's rotation status and last rotation date, planning a manual rotation for asymmetric/HMAC keys that do not support automatic rotation, diagnosing why EnableKeyRotation fails (Disabled/PendingDeletion key, asymmetric usage, replica key, missing key-policy permission), confirming CloudTrail EnableKeyRotation events, or validating cryptographic-agility posture across a fleet of CMKs.20 activation_triggers: enable KMS key rotation, rotate KMS key, verify key rotation, GetKeyRotationStatus, EnableKeyRotation, automatic key rotation, manual key rotation, backing key, Multi-Region key rotation, replica key rotation, asymmetric key rotation, HMAC key rotation, re-encrypt with new key, cryptographic agility, KMS rotation failed21 invocation_schema: 'Input: either (a) a KMS key configuration (describe-key output) plus the intended operation (enable-rotation, verify-rotation, disable-rotation, plan-manual-rotation, diagnose-rotation), OR (b) a key-id + operation for live-account execution. Output: deterministic OPERATION / VERDICT / PRE_CHECKS / STEPS / POST_VERIFY / NOTES block per rotation, where VERDICT is one of READY, BLOCKED, COMPLETED.'22 version: 0.1.023 author: Jacky Chan — AWS Community Builder24 keywords: KMS, key rotation, backing key, cryptographic material, customer managed key, CMK, AWS managed key, Multi-Region key, replica key, asymmetric key, RSA_2048, ECC_NIST_P256, HMAC_256, SYMMETRIC_DEFAULT, EnableKeyRotation, GetKeyRotationStatus, CloudHSM custom key store, key policy, re-encrypt, cryptographic agility25 tags: aws, kms, security, encryption, key-management, rotation, compliance, operate26---2728# KMS Key Rotation Operator2930## What this skill does3132Executes KMS key rotation operations correctly and safely. Runs33deterministic pre-checks before any state-changing CLI (key Enabled,34not PendingDeletion, symmetric SYMMETRIC_DEFAULT usage, Multi-Region35primary not replica, EnableKeyRotation permission in the key policy,36not a custom key store with external rotation), executes the37`enable-key-rotation` / `disable-key-rotation` CLI behind a CONFIRM38gate, and verifies the result by confirming39`get-key-rotation-status` returns `Enabled: true` and CloudTrail shows40the `EnableKeyRotation` event. Every enable-rotation produces a41cryptographic-material lifecycle note (old backing material retained42for decrypt of existing ciphertext; new material encrypts all new43operations transparently). Every asymmetric/HMAC key plan routes to44manual rotation (create new key, update callers, re-encrypt) since45automatic rotation is not supported.4647## Quick navigation4849| Section | What it covers | When to read it |50|---|---|---|51| **§ Quick reference** | Verdict thresholds (BLOCKED/READY/COMPLETED) + pre-check priority | Before any operation |52| **§ Mindset** | Why rotation is transparent, the asymmetric-gap, the confirm gate | Understanding the safety model |53| **§ Pre-flight** | Key metadata gate — Enabled state, PendingDeletion, Multi-Region, custom key store | Before executing any CLI |54| **§ Process** | Per-operation planning: enable, verify, disable, plan-manual, diagnose | When choosing which operation to run |55| **§ Output format** | Structured OPERATION/VERDICT/PRE_CHECKS/STEPS/POST_VERIFY template | Formatting the response |56| **§ Anti-Patterns** | NEVER list — common mistakes that break encryption or strand data | Review before risky operations |57| **§ Pre-flight safety** | Capture pre-state, CloudTrail trail verification, key policy check | Defense-in-depth |5859## Quick reference — verdict thresholds6061| Verdict | Trigger condition | Action |62|---|---|---|63| `BLOCKED` | One or more pre-checks failed (key Disabled, key PendingDeletion, asymmetric/HMAC usage with auto-rotation requested, replica key with auto-rotation requested, missing EnableKeyRotation permission, custom key store with external rotation) | List failures, do NOT execute |64| `READY` | All pre-checks passed; awaiting CONFIRM gate | Emit exact CLI sequence, wait for operator yes |65| `COMPLETED` | Rotation enable/disable finished and post-verification passed (`get-key-rotation-status` matches intent, CloudTrail event present, key policy unchanged, applications using key ARN still work) | Emit verification results, monitoring plan |6667**Priority order for pre-checks (apply in this sequence, all must pass68for READY):**69701. **Key reachability** — key exists (`describe-key` does not return71 `NotFoundException`), `Enabled` true, `KeyState: Enabled`.722. **No deletion pending** — `KeyState` is NOT `PendingDeletion` (no73 rotation during the deletion window).743. **Key supports automatic rotation** — `KeySpec` is75 `SYMMETRIC_DEFAULT` (or `AES_256` for multi-Region primary) AND76 `KeyUsage: ENCRYPT_DECRYPT` AND `Origin: AWS_KMS`. Asymmetric,77 HMAC, and external-key-material keys do NOT support automatic78 rotation.794. **Multi-Region primary** — for Multi-Region keys, rotation is80 controlled by the primary key. A replica key81 (`MultiRegionConfiguration.PrimaryArmy` != self) inherits the82 primary's rotation status; `EnableKeyRotation` on a replica fails.835. **Key policy permission** — the calling identity must have84 `kms:EnableKeyRotation` (or `kms:DisableKeyRotation`) on the key85 ARN. The key's own resource-based policy must allow the caller, or86 the caller's identity-based policy must grant it. Cross-account87 callers need both sides.886. **Custom key store check** — for `Origin: AWS_CLOUDHSM`, rotation89 is supported (KMS rotates the backing key in the CloudHSM cluster),90 but the cluster must be `ACTIVE`. For `Origin: EXTERNAL`, rotation91 is NOT supported (you manage the key material externally).927. **Schedule intent clarity** — `enable-key-rotation` accepts an93 optional `--rotation-period-in-days` (7-365, default 365). Confirm94 the intended cadence before enabling.9596**Cost/time baselines (2026):**9798- Customer-managed CMK: $1.00/key/month (regardless of rotation).99- Automatic rotation: no additional per-rotation fee. The CMK keeps100 its key ID and ARN; KMS retains old backing material for decrypt.101- Asymmetric keys (RSA, ECC): $1.00/key/month; do NOT support102 automatic rotation. Manual rotation = create new key + update103 callers + optional re-encrypt.104- HMAC keys: $1.00/key/month; do NOT support automatic rotation.105- Multi-Region keys: $1.00 per primary + $1.00 per replica.106- CloudTrail `EnableKeyRotation` / `DisableKeyRotation` events: free107 (management events).108- Re-encryption cost (manual rotation): `$0.03` per 10,000109 `Encrypt`/`Decrypt` requests. Re-encrypting a large S3 bucket or110 DynamoDB table is the dominant cost, not KMS itself.111112## Mindset113114**One-line takeaway:** automatic KMS key rotation is transparent to115applications — the key ID and ARN do not change, and old backing116material is retained so existing ciphertext remains decryptable.117Driven by three KMS realities:118119- **Rotation swaps backing material, not the key.** A KMS key is a120 logical construct (key ID + ARN + policy) backed by cryptographic121 material. Automatic rotation creates new backing material under the122 same key ID. All new `Encrypt` operations use the new material; all123 `Decrypt` operations on existing ciphertext use the material that124 originally encrypted it (KMS tracks which material produced each125 ciphertext via the encryption context). Applications see no change.126127- **Asymmetric and HMAC keys are the rotation blind spot.** Automatic128 rotation is supported ONLY on symmetric ENCRYPT_DECRYPT keys with129 `Origin: AWS_KMS` (and CloudHSM-backed symmetric keys). RSA, ECDSA,130 HMAC, and external-material keys do NOT support automatic rotation.131 For these, you must rotate manually: create a new key, update all132 callers to use the new key ARN, and optionally re-encrypt old data.133 This is a significant operational gap — auditors asking "are all134 keys rotating annually?" need to be told that asymmetric keys are135 manually rotated.136137- **A Multi-Region replica key's rotation is set on the primary.**138 Calling `EnableKeyRotation` on a replica returns139 `InvalidOperationException`. Multi-Region replica keys share the140 same cryptographic material as the primary — when the primary's141 backing material rotates, replicas receive the new material142 automatically. Verify rotation on the primary's143 `get-key-rotation-status`.144145## Pre-flight: key metadata gate146147Run before classification. Misclassifying these produces wrong plans.148149Pagination + live-account pre-flight commands moved verbatim to150`references/diagnostic-commands.md` (load on demand).151152**Malformed input:** if the input JSON is invalid or missing required153fields, emit `VERDICT: ERROR` with `REASON: Key configuration is not154valid JSON or is missing required fields — cannot plan.` and155`REMEDIATION: Re-fetch with aws kms describe-key --key-id <id> --output156json and re-plan.`157158| Key attribute | Effect on operation |159|---|---|160| `KeyState: PendingDeletion` + `DeletionDate` set | BLOCKED — key in deletion window (7-30 days). Cancel deletion (`schedule-key-deletion` with `--pending-window-in-days 0` is not supported; you must wait or use `cancel-key-deletion` to restore). |161| `KeyState: Disabled` | BLOCKED — key disabled. `EnableKeyRotation` requires `Enabled: true`. Call `enable-key` first. |162| `KeyUsage: SIGN_VERIFY` (asymmetric) | BLOCKED for automatic rotation. Manual rotation required. |163| `KeyUsage: GENERATE_VERIFY_MAC` (HMAC) | BLOCKED for automatic rotation. Manual rotation required. |164| `KeySpec: RSA_2048` / `ECC_NIST_P256` etc. | BLOCKED for automatic rotation. Manual rotation required. |165| `Origin: EXTERNAL` (BYOK / imported material) | BLOCKED for automatic rotation. Re-import new material to rotate. |166| `Origin: AWS_CLOUDHSM` | Supported if the cluster is `ACTIVE`. KMS rotates the backing key in the CloudHSM. |167| `MultiRegionConfiguration.MultiRegionKeyType: REPLICA` | BLOCKED for `EnableKeyRotation` on the replica. Enable on the primary; replica inherits. |168| `MultiRegionConfiguration.MultiRegionKeyType: PRIMARY` | OK — rotation propagates to all replicas automatically. |169| Key policy denies caller `kms:EnableKeyRotation` | BLOCKED — add the permission to the policy (or call from a role that already has it). |170| `Enabled: false` in `get-key-rotation-status` | Not an error — rotation is currently disabled. The operation `enable-rotation` will enable it. |171| `Enabled: true` in `get-key-rotation-status` | If the operation is `enable-rotation`, no-op or update `RotationPeriodInSeconds`. If `disable-rotation`, plan the disable. |172173## Process — operation planning (apply in order)174175### Step 0: Expert knowledge — non-obvious KMS behaviors176177Step-0 expert behaviors moved verbatim to `references/advanced-patterns.md`178(backing material, rotation period, aliases, grants, AWS-managed keys, more).179180### Step 1: Pre-check gate — BLOCKED if any check fails181182Run ALL pre-checks for the chosen operation. If ANY fails, the verdict183is BLOCKED with the failed checks in PRE_CHECKS. Do NOT execute.184185**For ALL operations:**1861. Key exists (`describe-key` does not return `NotFoundException`).1872. Key is NOT `PendingDeletion` (`DeletionDate` absent,188 `KeyState != PendingDeletion`).1893. Calling identity has `kms:GetKeyRotationStatus` on the key (for190 verify-rotation and diagnose-rotation).191192**For enable-rotation (`enable-key-rotation --key-id`):**1934. `KeyState: Enabled` (not `Disabled`).1945. `KeySpec: SYMMETRIC_DEFAULT` (or AES variant).1956. `KeyUsage: ENCRYPT_DECRYPT`.1967. `Origin: AWS_KMS` OR `Origin: AWS_CLOUDHSM` (with cluster ACTIVE).1978. NOT a Multi-Region replica198 (`MultiRegionConfiguration.MultiRegionKeyType == PRIMARY` or key is199 single-region).2009. Calling identity has `kms:EnableKeyRotation` on the key ARN.20110. (Optional) `--rotation-period-in-days` is in [7, 365], if202 specified.203204**For verify-rotation (read-only, no BLOCKED gate for state):**2054. `get-key-rotation-status` returns `Enabled` and `NextRotationDate`.2065. CloudTrail shows an `EnableKeyRotation` event matching the key ARN207 (within the last rotation period).2086. (Optional) `NextRotationDate` is within the expected window.209210**For disable-rotation (`disable-key-rotation --key-id`):**2114. `KeyState: Enabled`.2125. Current `get-key-rotation-status.Enabled: true` (otherwise it is a213 no-op).2146. Calling identity has `kms:DisableKeyRotation` on the key ARN.2157. (Advisory) Disabling rotation is rare and usually a compliance216 violation. Confirm the operator has a documented reason.217218**For plan-manual-rotation (asymmetric / HMAC / external-material):**2194. Key is asymmetric (`KeyUsage: SIGN_VERIFY`), HMAC220 (`GENERATE_VERIFY_MAC`), or `Origin: EXTERNAL`.2215. Operator has `kms:CreateKey` permission (to create the new key).2226. List of all callers / aliases that reference the key — needed to223 plan the cutover.2247. (Optional) The set of ciphertexts / signatures / MACs that need225 re-encryption or re-signing (for compliance).226227**For diagnose-rotation (read-only):**2284. Read `get-key-rotation-status`, CloudTrail events, and the229 failure-mode table to identify why rotation cannot be enabled or230 why it did not run.231232**Rotation failure-mode table (use during diagnose-rotation):**233234Rotation failure-mode table (API errors -> fixes) moved verbatim to235`references/error-handling.md` (load on demand).236237### Step 2: READY — emit operation plan238239If all pre-checks pass, emit `VERDICT: READY` with the exact CLI240sequence and the CONFIRM gate. The plan includes:241242- The exact AWS CLI command with all flags populated from the key243 configuration.244- The expected `RotationPeriodInSeconds` (365 days default, or the245 specified value).246- The expected side-effects (rotation status flips to `Enabled`,247 `NextRotationDate` is set to ~365 days from now, key policy248 unchanged, applications unaffected).249- The CONFIRM gate prompt.250- The verification step (`get-key-rotation-status` + CloudTrail +251 application spot-check).252253### Step 3: Execute behind CONFIRM gate254255- **MANDATORY CONFIRMATION GATE.** Before any state-changing CLI256 (`enable-key-rotation`, `disable-key-rotation`, `enable-key`,257 `disable-key`, `schedule-key-deletion`, `cancel-key-deletion`,258 `create-key`, `update-alias`), emit:259 `CONFIRM: About to <operation> on KMS key <key-id> (account260 <account> region <region>). This will <consequence>. Proceed?261 (yes/no)`. Do NOT execute until the operator confirms.262- Capture pre-state for rollback: `aws kms describe-key --key-id <id>263 --output json > /tmp/<id>-describe-pre-$(date +%s).json` AND264 `aws kms get-key-rotation-status --key-id <id> --output json >265 /tmp/<id>-rotation-pre-$(date +%s).json`.266- Execute the CLI. `enable-key-rotation` is synchronous — it returns267 once the rotation schedule is set. The actual material rotation268 happens at `NextRotationDate`.269- For manual rotations: the cutover (alias update or caller update)270 is the state-changing step. Capture the alias pre-state.271272### Step 4: Post-verification — COMPLETED273274After the CLI completes, run post-verification. ALL checks must pass275for `COMPLETED`.2762771. `get-key-rotation-status --key-id <id>` — confirm `Enabled: true`278 (or `false` for disable-rotation) and `NextRotationDate` is set279 (or absent for disable).2802. CloudTrail shows the `EnableKeyRotation` (or `DisableKeyRotation`)281 event with the key ARN and the caller's identity.2823. `describe-key --key-id <id>` — confirm `KeyState: Enabled` (the283 key itself is unaffected by the rotation-status change).2844. `get-key-policy --key-id <id> --policy-name default` — confirm285 the policy is unchanged (rotation does not modify policy).2865. `list-grants --key-id <id>` — confirm grants are unchanged.2876. Spot-check: an application using the key ARN performs a test288 `Encrypt` + `Decrypt` cycle successfully (or confirm via metrics289 that no `KMSKeyUnavailableException` or `AccessDeniedException`290 spike occurred).291292If ANY verification fails, emit `VERDICT: ERROR` with the failure293details — do not claim COMPLETED. A failed verification typically294means the key policy was inadvertently modified or the key was295simultaneously disabled by another process.296297## Output format (per operation)298299```text300OPERATION: <enable-rotation | verify-rotation | disable-rotation | plan-manual-rotation | diagnose-rotation>301VERDICT: READY | BLOCKED | COMPLETED302TARGET: <key-id> (alias: <alias-or-"none">, account <account>, region <region>)303PRE_CHECKS:304 - [PASS] <check description>305 - [FAIL] <check description> — <reason>306STEPS:307 1. <CLI command with flags populated>308 2. <wait / monitoring command>309 3. <next step>310POST_VERIFY:311 - [PASS] <verification description>312 - [FAIL] <verification description> — <reason>313NOTES: <rotation period, material lifecycle, monitoring, caveats>314```315316### Worked example — enable-rotation (symmetric CMK)317318```text319OPERATION: enable-rotation320VERDICT: READY321TARGET: arn:aws:kms:us-east-1:111111111111:key/abcd1234-... (alias:322 alias/prod-app-encryption-key, account 111111111111, region323 us-east-1)324PRE_CHECKS:325 - [PASS] Key exists, KeyState: Enabled326 - [PASS] Not PendingDeletion (DeletionDate absent)327 - [PASS] KeySpec: SYMMETRIC_DEFAULT, KeyUsage: ENCRYPT_DECRYPT328 - [PASS] Origin: AWS_KMS (supports automatic rotation)329 - [PASS] Single-region key (not a Multi-Region replica)330 - [PASS] Calling role has kms:EnableKeyRotation via key policy331 statement allowing arn:aws:iam::111111111111:role/SecurityAdmin332 - [PASS] RotationPeriodInSeconds: 365 (default — annual)333STEPS:334 1. CONFIRM: About to enable automatic backing-key rotation on KMS335 key alias/prod-app-encryption-key336 (arn:aws:kms:us-east-1:111111111111:key/abcd1234-...) in account337 111111111111 region us-east-1. Rotation period: 365 days. The key338 ID, ARN, policy, grants, and aliases are unchanged. Existing339 ciphertext remains decryptable. New Encrypt operations use the340 new backing material after the first rotation. Proceed? (yes/no)341 2. aws kms enable-key-rotation \342 --key-id arn:aws:kms:us-east-1:111111111111:key/abcd1234-...343 3. (Optional) Verify immediately:344 aws kms get-key-rotation-status \345 --key-id arn:aws:kms:us-east-1:111111111111:key/abcd1234-...346POST_VERIFY:347 - (pending execution)348NOTES:349 - The first rotation will occur within 24 hours of NextRotationDate350 (approximately 365 days from enablement). KMS performs the351 material swap; no application action is needed.352 - Old backing material is retained indefinitely (until the key is353 deleted). Existing ciphertext encrypted with old material remains354 decryptable — no re-encryption required.355 - CloudTrail will log the EnableKeyRotation event immediately. The356 actual material rotation does NOT produce a separate CloudTrail357 event; verify via NextRotationDate advancing.358 - For compliance evidence, capture quarterly:359 aws kms get-key-rotation-status --key-id <id>360 and store the output with NextRotationDate.361```362363### Worked example — plan-manual-rotation (asymmetric RSA key)364365Full plan-manual-rotation worked example moved verbatim to366`references/worked-examples.md` (load on demand).367368### Worked example — diagnose-rotation (BLOCKED with remediation)369370Full diagnose-rotation worked example moved verbatim to371`references/worked-examples.md` (load on demand).372373## Anti-Patterns — NEVER374375- NEVER call `enable-key-rotation` on an asymmetric, HMAC, or376 external-material key without first confirming it is a symmetric377 AWS_KMS-origin key. The API returns `InvalidOperationException`;378 the operator should plan a manual rotation instead.379380- NEVER call `enable-key-rotation` on a Multi-Region replica key. The381 API returns `InvalidOperationException`. Enable rotation on the382 primary; the replica inherits the status.383384- NEVER disable or delete an old key immediately after a manual385 rotation. Existing ciphertext, signatures, or MACs produced with the386 old key require the old key to be `Enabled` for decrypt / verify.387 Disable only after confirming all artifacts have been re-encrypted /388 re-signed or are no longer needed (typically 90+ days).389390- NEVER assume `get-key-rotation-status.Enabled: true` means a391 rotation has occurred. It means rotation is SCHEDULED. The actual392 material swap happens at `NextRotationDate`. For proof that a393 rotation ran, compare `NextRotationDate` advancing over time or394 inspect the key's internal material versions (KMS does not expose395 material IDs publicly — `NextRotationDate` advancing is the396 observable signal).397398- NEVER assume AWS-managed keys (`aws/s3`, `aws/rds`, etc.) rotate399 annually. They rotate approximately every 3 years on an AWS-managed400 schedule. You CANNOT enable, disable, or configure rotation on401 AWS-managed keys. For annual rotation compliance, use customer-402 managed keys.403404- NEVER modify the key policy as part of a rotation operation. The405 policy is independent of the backing material. A policy change406 during rotation creates confusion about which change caused any407 subsequent access issue.408409- NEVER assume `RotationPeriodInSeconds` is fixed at 365 days. It is410 configurable (7-365 days, default 365). Always read the current411 value from `get-key-rotation-status` before planning.412413- NEVER confuse `enable-key-rotation` with `rotate-key-on-demand`414 (2024+ feature for immediate material rotation on symmetric keys).415 `enable-key-rotation` schedules recurring rotation;416 `rotate-key-on-demand` performs an immediate material swap. Use417 on-demand for incident response (suspected key compromise); use418 scheduled for routine cryptographic agility.419420- NEVER call `schedule-key-deletion` to "force a rotation." Deletion421 is irreversible within the 7-30 day window; `cancel-key-deletion`422 restores the key but cancels its rotation schedule. Use423 `rotate-key-on-demand` for an immediate rotation instead.424425- NEVER hard-code a key ARN in application configuration if you can426 use an alias. Aliases make manual rotation a one-line `update-alias`427 cutover; ARNs require updating every caller.428429- NEVER assume CloudTrail logs the actual material rotation. CloudTrail430 logs `EnableKeyRotation` and `DisableKeyRotation` (management431 events). The material swap itself is an internal KMS operation with432 no separate CloudTrail event. Use `NextRotationDate` advancing as433 the observable signal.434435- NEVER enable rotation on a key whose CloudHSM cluster is436 `DEGRADED` or `DISCONNECTED`. The `enable-key-rotation` API may437 succeed but the actual rotation will fail until the cluster is438 `ACTIVE`. Verify cluster state first.439440- NEVER re-create grants after an automatic rotation. Grants are per-441 key-ID and survive rotation. Re-creating grants can create442 conflicting permissions and is unnecessary.443444- NEVER call `disable-key-rotation` without a documented compliance445 exception. Disabling rotation is almost always a policy violation.446 If the goal is to "pause" rotation temporarily, leave rotation447 enabled and address the underlying concern instead.448449- NEVER auto-execute a state-changing KMS CLI without the CONFIRM450 gate. Rotation operations are reversible, but disabling a key or451 scheduling deletion during a "rotation" workflow can cause452 immediate application outages.453454## Pre-flight safety checks (run before any remediation CLI)455456Pre-flight safety checks moved verbatim to457`references/diagnostic-commands.md` (load on demand).458459## Recent AWS features (2024-2026)460461Recent-feature details moved verbatim to462`references/advanced-patterns.md` (load on demand).463464465## References (load on demand)466467- [`references/worked-examples.md`](references/worked-examples.md) — secondary worked examples: plan-manual-rotation (asymmetric RSA), diagnose-rotation (BLOCKED replica key).468- [`references/advanced-patterns.md`](references/advanced-patterns.md) — Step-0 expert KMS rotation behaviors, recent AWS features 2024-2026.469- [`references/error-handling.md`](references/error-handling.md) — rotation failure-mode table (symptom / root cause / fix).470- [`references/diagnostic-commands.md`](references/diagnostic-commands.md) — sweep pagination, live-account pre-flight command listing, pre-flight safety checks.471- [`references/key-type-and-rotation-matrix.md`](references/key-type-and-rotation-matrix.md) — key type rotation support matrix and procedures.472- [`references/manual-rotation-procedures.md`](references/manual-rotation-procedures.md) — manual rotation procedures (caller identification, cutover).473474## Domain475476AWS CloudOps / KMS Key Rotation, Cryptographic Agility & Compliance.477478## AWS documentation479480- **AWS KMS Developer Guide** — https://docs.aws.amazon.com/kms/latest/developerguide/481- **Rotating keys** — https://docs.aws.amazon.com/kms/latest/developerguide/rotate-keys.html482- **Automatic key rotation** — https://docs.aws.amazon.com/kms/latest/developerguide/rotate-keys.html#rotate-keys-how-it-works483- **Manual key rotation** — https://docs.aws.amazon.com/kms/latest/developerguide/rotate-keys.html#rotating-keys-manually484- **Multi-Region keys** — https://docs.aws.amazon.com/kms/latest/developerguide/multi-region-keys-manage.html485- **Custom key stores** — https://docs.aws.amazon.com/kms/latest/developerguide/custom-key-store-overview.html486- **KMS API Reference** — https://docs.aws.amazon.com/kms/latest/APIReference/487- **KMS CLI Reference** — https://docs.aws.amazon.com/cli/latest/reference/kms/488- **KMS key quotas** — https://docs.aws.amazon.com/kms/latest/developerguide/resource-limits.html