KMS Key Deployer
An AWS CloudOps agent skill that provisions AWS KMS customer-managed keys
(CMKs) with correct production defaults. Emits a READY_TO_DEPLOY checklist
verifying every configuration item.
Quick navigation
| Need |
Section |
| What MUST be in the response |
"STRICT output contract" |
| Why the provisioning order matters |
"Reasoning framework" |
| What to verify before provisioning |
"Prerequisites" |
| The ordered provisioning steps |
"Deployment procedure" |
| Common silent-failure pitfalls |
"NEVER" |
| Key policy, grants, multi-Region, CloudHSM |
"Deployment procedure" Steps 2-8 |
| Workload-specific defaults |
"Workload matrix" |
| 2024-2026 feature changes |
"Recent AWS features" |
| Deep CLI sequences |
references/deployment-cli-commands.md |
| Key policy, grants, multi-Region, CloudHSM, cross-account, envelope |
references/key-policy-and-multiregion-guide.md |
STRICT output contract
When this skill is invoked with a KMS key provisioning request (key
alias, usage, key type, or a partial existing configuration), the agent
MUST respond with the READY_TO_DEPLOY checklist defined in "Output
format" using the literal all-caps labels KEY:, VERDICT:,
CHECKLIST:, and VERIFICATION_COMMANDS:. Do NOT preface the
checklist with prose, headings, or disclaimers — emit the block as the
first lines of the response.
Required output structure
KEY: <alias-or-key-id> — the KMS key being provisioned.
VERDICT: READY_TO_DEPLOY OR VERDICT: PREREQUISITES_MISSING.
CHECKLIST: followed by indented lines with status markers
([✓], [✗], [OPTIONAL], [INPUT NEEDED]).
VERIFICATION_COMMANDS: followed by indented aws kms ... commands.
FORBIDDEN output patterns
- No prose preamble before
KEY: — the first non-empty line MUST be KEY:.
- No markdown variants of labels — write
VERDICT:, not **VERDICT:**,
### Verdict, Verdict =, or `VERDICT`.
- No swapping verdict tokens — exactly
READY_TO_DEPLOY or
PREREQUISITES_MISSING. Not "ready", "missing", "BLOCKED", "OK".
- No omitting
VERIFICATION_COMMANDS: — include even when
PREREQUISITES_MISSING; the operator needs commands to verify gaps.
- No extra sections after
VERIFICATION_COMMANDS: — the checklist
block is the entire response. Put deeper explanation in references/.
- No status marker drift — use only
[✓], [✗], [OPTIONAL],
[INPUT NEEDED]. Do not invent [?], [!], [WARN], or emoji.
Perfect example (copy the shape exactly)
KEY: alias/payments-cmk
VERDICT: READY_TO_DEPLOY
CHECKLIST:
[✓] Key spec — SYMMETRIC_DEFAULT (AES-256-GCM)
[✓] Key usage — ENCRYPT_DECRYPT
[✓] Origin — AWS_KMS
[✓] Key administrators — arn:aws:iam::123456789012:role/kms-admin (kms:Create*, kms:Put*, kms:Enable*, ScheduleKeyDeletion)
[✓] Key users — arn:aws:iam::123456789012:role/payments-svc (kms:Encrypt, kms:Decrypt, kms:GenerateDataKey, kms:DescribeKey)
[✓] Root account break-glass — arn:aws:iam::123456789012:root (kms:*)
[✓] Automatic rotation — enabled (annual, symmetric only)
[✓] Alias — alias/payments-cmk
[✓] Deletion window — 30 days
[✓] Tags — Environment=production, Application=payments
[OPTIONAL] Multi-Region — single-Region (us-east-1) primary only
[OPTIONAL] Grants — none (key policy covers all callers)
VERIFICATION_COMMANDS:
aws kms describe-key --key-id alias/payments-cmk
aws kms get-key-rotation-status --key-id alias/payments-cmk
aws kms list-aliases --key-id <key-id>
aws kms list-resource-tags --key-id <key-id>
aws kms list-grants --key-id <key-id>
aws iam get-role-policy --role-name kms-admin --policy-name kms-admin-policy
Reasoning framework (why the provisioning order matters)
KMS key provisioning has dependency and ordering constraints that make
the procedure non-trivial. Applying configurations in the wrong order causes
locked-out keys, un-decryptable data, or compliance violations:
- Key spec + key usage FIRST — the
KeySpec and KeyUsage determine
what crypto operations the key supports. A SYMMETRIC_DEFAULT key cannot
sign; an RSA_4096 SIGN_VERIFY key cannot encrypt. Changing spec after
creation requires a new key and re-encrypting all data.
- Key policy separates administrators from users — the ONLY way to
grant CMK access (IAM alone is not enough). Conflating admin and user
produces lockouts (users disable the key) or over-permission (admins
decrypt production data).
- Root account break-glass — every CMK key policy MUST include account
root with
kms:*. Without this, an accidental policy lockout is
unrecoverable — AWS support cannot restore access.
- Aliases after key creation — human-readable names (
alias/<name>)
that decouple the application reference from the underlying key material
(useful for rotation cutover).
- Automatic rotation — symmetric CMKs support annual rotation (key
material only, ARN/ID unchanged). Asymmetric, HMAC, and multi-Region
primaries do NOT support auto-rotation.
- Multi-Region keys — primary + replicas share key material but have
independent key policies. Create primary first, then replicate. Cannot
auto-rotate.
- Deletion window — 7-30 day mandatory waiting period before irreversible
deletion. Set to 30 days for production to allow recovery from accidents.
Prerequisites (verify before deployment)
| Prerequisite |
Why it matters |
How to verify |
| AWS account root access or break-glass |
Every CMK policy MUST include root. |
aws sts get-caller-identity |
| Key administrator principal |
IAM role/user that can administer the key. |
aws iam get-role --role-name <admin-role> |
| Key user principals |
Application roles needing Encrypt/Decrypt/GenerateDataKey. |
aws iam get-role --role-name <app-role> |
| CloudHSM cluster (if custom key store) |
Must be ACTIVE with >= 2 HSMs across AZs. |
aws cloudhsmv2 describe-clusters |
| Cross-account caller IAM (if cross-account) |
Caller IAM must ALSO grant KMS actions. |
aws iam get-role in caller account |
| Alias name uniqueness |
Unique within account/Region. alias/aws/* reserved. |
aws kms list-aliases |
| IAM permissions |
Caller needs kms:CreateKey, iam:PutRolePolicy, kms:CreateAlias. |
aws sts get-caller-identity |
Deployment procedure (apply in order)
Step 1: Key spec + key usage selection
Symmetric (the common case):
| KeySpec |
KeyUsage |
What it does |
SYMMETRIC_DEFAULT |
ENCRYPT_DECRYPT |
AES-256-GCM. Default for 95% of workloads (EBS, S3, RDS, Lambda, Secrets Manager). |
Asymmetric / HMAC:
| KeySpec |
KeyUsage |
What it does |
RSA_2048 / RSA_3072 / RSA_4096 |
ENCRYPT_DECRYPT |
RSA encryption (public key downloadable) |
RSA_2048 / RSA_3072 / RSA_4096 |
SIGN_VERIFY |
RSA signing (code/document signing) |
ECC_NIST_P256 / P384 / P521 |
SIGN_VERIFY |
ECDSA signing (lower latency) |
ECC_NIST_P256 / P384 |
KEY_AGREEMENT |
ECDH key agreement (mTLS) |
HMAC_256 |
GENERATE_VERIFY_MAC |
HMAC-SHA-256 (JWT, API tokens) |
Choose SYMMETRIC_DEFAULT unless you have a specific reason not to.
It is the only spec supporting automatic rotation, AWS service integration,
and the cheapest.
Step 2: Key policy (separate administrators from users)
The key policy is the ONLY way to grant CMK access — IAM cannot override a
key policy denial. A production key policy contains four statements:
- Break-glass (root) —
kms:* on account root. Mandatory recovery path.
- Key administrators — lifecycle actions only (
Create*, Put*,
Disable*, ScheduleKeyDeletion). NO Encrypt/Decrypt.
- Key users —
Encrypt, Decrypt, ReEncrypt*, GenerateDataKey*,
DescribeKey.
- Grant creation — allows AWS service integrations to create grants
when
kms:GrantIsForAWSResource=true.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Enable IAM User Permissions (break-glass)",
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::123456789012:root" },
"Action": "kms:*", "Resource": "*"
},
{
"Sid": "Allow access for Key Administrators",
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::123456789012:role/kms-admin" },
"Action": ["kms:Create*","kms:Describe*","kms:Enable*","kms:List*",
"kms:Put*","kms:Update*","kms:Revoke*","kms:Disable*","kms:Get*",
"kms:Delete*","kms:ScheduleKeyDeletion","kms:CancelKeyDeletion",
"kms:RotateKeyOnDemand"],
"Resource": "*"
},
{
"Sid": "Allow use of the key",
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::123456789012:role/payments-svc" },
"Action": ["kms:Encrypt","kms:Decrypt","kms:ReEncrypt*",
"kms:GenerateDataKey*","kms:DescribeKey"],
"Resource": "*"
},
{
"Sid": "Allow attachment of persistent resources",
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::123456789012:role/payments-svc" },
"Action": ["kms:CreateGrant","kms:ListGrants","kms:RevokeGrant"],
"Resource": "*",
"Condition": { "Bool": { "kms:GrantIsForAWSResource": "true" } }
}
]
}
NEVER grant kms:* to anyone but root.
Step 3: Key administrators vs. key users (separation principle)
| Capability |
Key administrators |
Key users |
kms:Create*, kms:Put*, kms:Update* |
YES |
NO |
kms:Enable*, kms:Disable* |
YES |
NO |
kms:ScheduleKeyDeletion, kms:CancelKeyDeletion |
YES |
NO |
kms:Encrypt, kms:Decrypt, kms:GenerateDataKey* |
NO |
YES |
kms:Describe*, kms:List* |
YES |
YES (read-only) |
kms:CreateGrant |
NO |
YES (with condition) |
Step 4: Grants vs. key policy
- Key policy — persistent JSON on the key. Use for stable, long-term
access (app roles, break-glass root, key admin role).
- Grants — temporary, programmatic permissions with constraints. Use
for AWS service integrations (Lambda, EBS), temporary access (migration),
tighter scoping (Encrypt only on specific encryption context).
Grants are subject to the key policy and eventually consistent (~5s
propagation). Prefer key policy for human/long-term roles; grants for
service integrations and temporary access.
aws kms create-grant \
--key-id alias/payments-cmk \
--grantee-principal arn:aws:iam::123456789012:role/migration-tool \
--operations Decrypt \
--constraints '{"EncryptionContextSubset": {"department": "finance"}}' \
--retiring-principal arn:aws:iam::123456789012:role/kms-admin
Step 5: Aliases
aws kms create-alias --alias-name alias/payments-cmk --target-key-id <key-id>
- Prefix
alias/ mandatory. alias/aws/* reserved for AWS-managed keys.
- Can be updated to point at a different key (rotation cutover).
- Name after the workload (
alias/payments-cmk), not generic (alias/my-key).
Step 6: Automatic rotation
aws kms enable-key-rotation --key-id alias/payments-cmk
- Symmetric CMKs: annual auto-rotation. ARN, ID, policy unchanged.
Existing ciphertext remains decryptable.
- Asymmetric / HMAC: do NOT support auto-rotation. Manual rotation
required (create new key, update alias, re-encrypt).
- Multi-Region primaries: cannot auto-rotate (would desync replicas).
- Custom key store (CloudHSM): supports auto-rotation since 2023.
- On-demand rotation (2024-2025):
kms:RotateKeyOnDemand triggers
immediate rotation for eligible symmetric keys.
Step 7: Multi-Region keys (primary + replicas)
# Primary (multi-Region)
aws kms create-key --description "Payments CMK (primary)" \
--origin AWS_KMS --multi-region --policy file://policy.json
# Replica in us-west-2
aws kms replicate-key \
--key-id arn:aws:kms:us-east-1:123456789012:key/<primary-key-id> \
--replica-region us-west-2 --policy file://replica-policy.json
Each replica shares key material with the primary but has an INDEPENDENT
key policy. Multi-Region keys CANNOT auto-rotate. Use for cross-Region DR,
global DynamoDB table encryption, cross-Region EBS snapshot restore.
Step 8: Custom key store (CloudHSM)
For FIPS 140-2 Level 3 compliance or regulatory key custody:
# 1. CloudHSM cluster must be ACTIVE with >= 2 HSMs
aws cloudhsmv2 describe-clusters
# 2. Create custom key store linked to the CloudHSM cluster
aws kms create-custom-key-store \
--custom-key-store-name payments-hsm-keystore \
--cloud-hsm-cluster-id cluster-xxx \
--trust-anchor certificate.pem \
--key-store-admin-credentials <kmsuser-password> \
--hsm-credentials <hsm-password>
# 3. Connect the key store
aws kms connect-custom-key-store --custom-key-store-id cks-xxx
# 4. Create key in the custom key store
aws kms create-key --custom-key-store-id cks-xxx \
--description "Payments CMK (CloudHSM)" --policy file://policy.json
Rules:
kmsuser CU must be logged out before KMS connects.
- Cluster must have >= 2 active HSMs across different AZs.
- Supports
SYMMETRIC_DEFAULT, RSA_*, ECC_*, HMAC_256.
- A disconnected key store blocks all Encrypt/Decrypt on its keys.
Step 9: Deletion window
aws kms schedule-key-deletion --key-id alias/payments-cmk --pending-window-in-days 30
- Window: 7-30 days. Default is 30 days. For production, ALWAYS set 30 days.
- Deletion is IRREVERSIBLE — once the window expires, the key material is
destroyed and all ciphertext encrypted under the key becomes permanently
unrecoverable.
- The key is in
PendingDeletion state during the window. It can be
cancelled with CancelKeyDeletion.
- During
PendingDeletion, the key CANNOT be used for Encrypt or
GenerateDataKey, but CAN be used for Decrypt (so existing data can be
migrated to a new key).
Step 10: Tagging + verification
aws kms tag-resource --key-id <key-id> \
--tags '[{"TagKey":"Environment","TagValue":"production"}]'
aws kms describe-key --key-id alias/payments-cmk
aws kms get-key-rotation-status --key-id alias/payments-cmk
aws kms get-key-policy --key-id <key-id> --policy-name default
Envelope encryption and cross-account access
Envelope encryption: KMS has a 4 KB payload limit. Use
GenerateDataKey to get a plaintext data key + encrypted data key, encrypt
payloads client-side (AWS Encryption SDK), store ciphertext + encrypted key.
Decrypt by calling Decrypt on the encrypted data key.
aws kms generate-data-key --key-id alias/payments-cmk \
--key-spec AES_256 \
--encryption-context '{"department":"finance","app":"payments"}'
aws kms decrypt --ciphertext-blob fileb://encrypted-data-key.bin \
--encryption-context '{"department":"finance","app":"payments"}'
The encryption context is authenticated AAD — MUST be identical on Encrypt
and Decrypt. Full reference in references/key-policy-and-multiregion-guide.md.
Cross-account access: KMS is a "both-must-allow" service. Account A's
key policy must grant account B, AND account B's IAM must grant the KMS
actions. A missing key policy statement fails silently with
AccessDeniedException. Full reference in
references/key-policy-and-multiregion-guide.md.
Edge-case handling
Edge-case quick list moved verbatim to
references/key-policy-and-multiregion-guide.md (load on demand).
Workload matrix
| Workload |
KeySpec |
Rotation |
Multi-Region |
Origin |
Notes |
| EBS / S3 / RDS / Lambda env vars |
SYMMETRIC_DEFAULT |
Annual |
Optional |
AWS_KMS |
Default for AWS service integration |
| DynamoDB / Aurora / SQS / SNS |
SYMMETRIC_DEFAULT |
Annual |
Optional |
AWS_KMS |
Use CMK for full control |
| Secrets Manager |
SYMMETRIC_DEFAULT |
Annual |
No |
AWS_KMS |
One CMK per secret-class |
| Code signing (Signer) |
RSA_4096 SIGN_VERIFY |
Manual |
Optional |
AWS_KMS |
Cannot auto-rotate |
| JWT / API tokens |
HMAC_256 |
Manual |
Optional |
AWS_KMS |
Cannot auto-rotate |
| Cross-Region DR |
SYMMETRIC_DEFAULT |
Manual |
YES |
AWS_KMS |
Replica per Region |
| FIPS / regulatory |
SYMMETRIC_DEFAULT |
Annual |
No |
CloudHSM |
Custom key store |
| Document signing |
ECC_NIST_P384 SIGN_VERIFY |
Manual |
Optional |
AWS_KMS |
Lower latency than RSA |
Recent AWS features (2024-2026)
2024-2026 feature details moved verbatim to
references/advanced-patterns.md (load on demand).
NEVER (top 5 — full list of 13 anti-patterns in references)
- NEVER create a CMK without the account root as break-glass
(
{"AWS": "arn:aws:iam::<account>:root"} with kms:*). Without root,
an accidental lockout is unrecoverable — AWS support cannot help.
- NEVER grant
kms:* to any non-root principal. Use scoped statements for
users (Encrypt/Decrypt/GenerateDataKey) vs administrators (Create*/Disable*).
- NEVER combine key administrator and key user into one role. Separation of
duties: admins manage lifecycle, users access data — never both.
- NEVER skip automatic rotation on a
SYMMETRIC_DEFAULT CMK. Annual rotation
is free, invisible to callers, and limits blast radius of compromise.
- NEVER delete a CMK without confirming no ciphertext is encrypted under it.
Audit CloudTrail for recent Encrypt/GenerateDataKey usage.
Expert heuristic — choosing key spec, administrators, and users
- Key spec — default to
SYMMETRIC_DEFAULT. Choose asymmetric only for
public-key encryption, digital signatures verifiable outside AWS, or HMAC.
- Administrators — one
kms-admin role per security team. Lifecycle
actions only, NO kms:Decrypt.
- Users — one role per application. Never grant to broad groups like
"Developers" — that lets engineers read production ciphertext.
- Break-glass — root always in the policy with
kms:*. Not a violation
of least privilege — it is the recovery path.
- Rotation — symmetric: on; asymmetric/HMAC: document manual procedure.
- Multi-Region — only when needed (cross-Region DR, global tables).
Single-Region is the right default.
- Encryption context — always include identifying fields like
{"app":"payments","env":"prod"}. Scopes grants, provides audit trail.
Pre-flight safety checks (run before any provisioning CLI)
Pre-flight command listing moved verbatim to
references/deployment-cli-commands.md (load on demand).
Output format — MANDATORY literal labels
When invoked with a key provisioning request, your ENTIRE response MUST
be the checklist block below. The labels are case-sensitive all-caps
keywords — write them EXACTLY as shown. Do NOT write a preamble. Start
with KEY: and stop after the VERIFICATION_COMMANDS: block.
KEY: <alias-or-key-id>
VERDICT: READY_TO_DEPLOY | PREREQUISITES_MISSING
CHECKLIST:
[✓] Key spec — <SYMMETRIC_DEFAULT | RSA_4096 | HMAC_256 | ...>
[✓] Key usage — <ENCRYPT_DECRYPT | SIGN_VERIFY | GENERATE_VERIFY_MAC | KEY_AGREEMENT>
[✓] Origin — <AWS_KMS | AWS_CLOUDHSM | EXTERNAL_KEY_STORE>
[✓] Key administrators — <admin-role-arn> (lifecycle actions only, no Encrypt/Decrypt)
[✓] Key users — <app-role-arns> (Encrypt, Decrypt, GenerateDataKey)
[✓] Root account break-glass — arn:aws:iam::<account>:root (kms:*)
[✓] Automatic rotation — <enabled annual | not supported for this spec>
[✓] Alias — alias/<name>
[✓] Deletion window — <7-30 days>
[✓] Tags — <key=value pairs>
[OPTIONAL] Multi-Region — <primary only | primary + replicas in <regions>>
[OPTIONAL] Grants — <none | service integrations>
VERIFICATION_COMMANDS:
aws kms describe-key --key-id alias/<name>
aws kms get-key-rotation-status --key-id alias/<name>
aws kms get-key-policy --key-id <key-id> --policy-name default
aws kms list-aliases --key-id <key-id>
aws kms list-resource-tags --key-id <key-id>
aws kms list-grants --key-id <key-id>
Status marker semantics:
[✓] — applied and verified.
[✗] — NOT applied or misconfigured. Cite the gap.
[OPTIONAL] — recommended but not required for the workload type.
[INPUT NEEDED] — prerequisite value missing; operator must provide.
PREREQUISITES_MISSING verdict: if any REQUIRED prerequisite is missing
(administrator role ARN, application role ARN, CloudHSM cluster), the
verdict is PREREQUISITES_MISSING with each gap listed.
References (load on demand)
references/deployment-cli-commands.md — full copy-pasteable CLI sequence for all 10 provisioning steps, Terraform/CloudFormation equivalents, pre-flight safety checks.
references/key-policy-and-multiregion-guide.md — key policy structure, grants, multi-Region, CloudHSM, envelope encryption, cross-account, edge-case handling.
references/advanced-patterns.md — recent AWS features 2024-2026 (on-demand rotation, HMAC GA, ECDH, XKS, VPC endpoint policies).
Domain
AWS CloudOps / KMS Cryptographic Key Provisioning.
AWS documentation
References
references/deployment-cli-commands.md — full copy-pasteable CLI command
sequence for all 10 provisioning steps, including Terraform equivalents.
references/key-policy-and-multiregion-guide.md — deep reference on key
policy structure, multi-Region internals, CloudHSM lifecycle, envelope
encryption, cross-account access, full NEVER list, and edge-case handling.
1---2name: kms-key-deployer3description: 'Provisions AWS KMS keys correctly: key type selection (symmetric AES-256, asymmetric RSA/ECDSA, HMAC), key spec, key policy with separated key administrators vs key users, grants vs key policy, aliases, automatic rotation (symmetric only, annually), multi-Region keys (primary + replicas), custom key store (CloudHSM), deletion window (7-30 days, irreversible), tagging, cross-account access (key policy + caller IAM), and envelope encryption pattern. Emits a READY_TO_DEPLOY checklist with every configuration item verified. Use when creating a new KMS key, deploying a customer-managed CMK, validating a key policy, enabling rotation, or configuring multi-Region keys. Triggers: create KMS key, customer managed key, CMK, key policy, key administrators, key users, KMS grants, automatic rotation, multi-Region keys, CloudHSM custom key store, envelope encryption, cross-account KMS.'4license: Apache-2.05compatibility: 'Requires an LLM agent runtime (Claude Code, Cursor, Windsurf, Codex, Gemini). For live deployment: AWS CLI v2 with kms, iam, cloudhsm, ram, and sts access. Works with Terraform aws_kms_key / aws_kms_alias / aws_kms_grant resources, CloudFormation AWS::KMS::Key / AWS::KMS::Alias, and SAM templates.'6metadata:7 source: https://skillmd.com/skills/jhkchan/kms-key-deployer8 domain: aws-cloudops9 complexity: high10 requires_llm: 'true'11 phase: '1'12 supports_pipeline: 'true'13 entry_point: 'false'14 family: Security15 task_type: deploy16 skill_class: capability17 lifecycle_status: active18 verdict_shape: READY_TO_DEPLOY | PREREQUISITES_MISSING19 version: 0.1.020 author: Jacky Chan — AWS Community Builder21 tags: aws, kms, security, cloudops, deploy, encryption, key-policy, multi-region22 dependencies: aws-orchestrator23 keywords: aws, kms, security, cloudops, deploy, provisioning, encryption, key-policy, cmk, envelope-encryption, multi-region, cloudhsm, key-rotation, asymmetric, grants24 when_to_use: Invoke when the user wants to create a new KMS customer-managed key (CMK), provision a multi-Region key, configure a CloudHSM custom key store key, validate a key policy for least-privilege, enable automatic rotation, set up cross-account access, or generate deployment CLI / IaC templates. Do NOT invoke for AWS-managed default keys (S3, EBS, DynamoDB defaults — these are not customer-controllable), or for TLS certificate key material (use ACM).25---2627# KMS Key Deployer2829An AWS CloudOps agent skill that provisions AWS KMS customer-managed keys30(CMKs) with correct production defaults. Emits a READY_TO_DEPLOY checklist31verifying every configuration item.3233## Quick navigation3435| Need | Section |36|---|---|37| What MUST be in the response | "STRICT output contract" |38| Why the provisioning order matters | "Reasoning framework" |39| What to verify before provisioning | "Prerequisites" |40| The ordered provisioning steps | "Deployment procedure" |41| Common silent-failure pitfalls | "NEVER" |42| Key policy, grants, multi-Region, CloudHSM | "Deployment procedure" Steps 2-8 |43| Workload-specific defaults | "Workload matrix" |44| 2024-2026 feature changes | "Recent AWS features" |45| Deep CLI sequences | `references/deployment-cli-commands.md` |46| Key policy, grants, multi-Region, CloudHSM, cross-account, envelope | `references/key-policy-and-multiregion-guide.md` |4748## STRICT output contract4950When this skill is invoked with a KMS key provisioning request (key51alias, usage, key type, or a partial existing configuration), the agent52MUST respond with the READY_TO_DEPLOY checklist defined in "Output53format" using the literal all-caps labels `KEY:`, `VERDICT:`,54`CHECKLIST:`, and `VERIFICATION_COMMANDS:`. Do NOT preface the55checklist with prose, headings, or disclaimers — emit the block as the56first lines of the response.5758### Required output structure59601. `KEY: <alias-or-key-id>` — the KMS key being provisioned.612. `VERDICT: READY_TO_DEPLOY` OR `VERDICT: PREREQUISITES_MISSING`.623. `CHECKLIST:` followed by indented lines with status markers63 (`[✓]`, `[✗]`, `[OPTIONAL]`, `[INPUT NEEDED]`).644. `VERIFICATION_COMMANDS:` followed by indented `aws kms ...` commands.6566### FORBIDDEN output patterns6768- **No prose preamble before `KEY:`** — the first non-empty line MUST be `KEY:`.69- **No markdown variants of labels** — write `VERDICT:`, not `**VERDICT:**`,70 `### Verdict`, `Verdict =`, or `` `VERDICT` ``.71- **No swapping verdict tokens** — exactly `READY_TO_DEPLOY` or72 `PREREQUISITES_MISSING`. Not "ready", "missing", "BLOCKED", "OK".73- **No omitting `VERIFICATION_COMMANDS:`** — include even when74 PREREQUISITES_MISSING; the operator needs commands to verify gaps.75- **No extra sections after `VERIFICATION_COMMANDS:`** — the checklist76 block is the entire response. Put deeper explanation in `references/`.77- **No status marker drift** — use only `[✓]`, `[✗]`, `[OPTIONAL]`,78 `[INPUT NEEDED]`. Do not invent `[?]`, `[!]`, `[WARN]`, or emoji.7980### Perfect example (copy the shape exactly)8182```text83KEY: alias/payments-cmk84VERDICT: READY_TO_DEPLOY85CHECKLIST:86 [✓] Key spec — SYMMETRIC_DEFAULT (AES-256-GCM)87 [✓] Key usage — ENCRYPT_DECRYPT88 [✓] Origin — AWS_KMS89 [✓] Key administrators — arn:aws:iam::123456789012:role/kms-admin (kms:Create*, kms:Put*, kms:Enable*, ScheduleKeyDeletion)90 [✓] Key users — arn:aws:iam::123456789012:role/payments-svc (kms:Encrypt, kms:Decrypt, kms:GenerateDataKey, kms:DescribeKey)91 [✓] Root account break-glass — arn:aws:iam::123456789012:root (kms:*)92 [✓] Automatic rotation — enabled (annual, symmetric only)93 [✓] Alias — alias/payments-cmk94 [✓] Deletion window — 30 days95 [✓] Tags — Environment=production, Application=payments96 [OPTIONAL] Multi-Region — single-Region (us-east-1) primary only97 [OPTIONAL] Grants — none (key policy covers all callers)98VERIFICATION_COMMANDS:99 aws kms describe-key --key-id alias/payments-cmk100 aws kms get-key-rotation-status --key-id alias/payments-cmk101 aws kms list-aliases --key-id <key-id>102 aws kms list-resource-tags --key-id <key-id>103 aws kms list-grants --key-id <key-id>104 aws iam get-role-policy --role-name kms-admin --policy-name kms-admin-policy105```106107## Reasoning framework (why the provisioning order matters)108109KMS key provisioning has **dependency and ordering constraints** that make110the procedure non-trivial. Applying configurations in the wrong order causes111locked-out keys, un-decryptable data, or compliance violations:1121131. **Key spec + key usage FIRST** — the `KeySpec` and `KeyUsage` determine114 what crypto operations the key supports. A `SYMMETRIC_DEFAULT` key cannot115 sign; an `RSA_4096` `SIGN_VERIFY` key cannot encrypt. Changing spec after116 creation requires a new key and re-encrypting all data.1172. **Key policy separates administrators from users** — the ONLY way to118 grant CMK access (IAM alone is not enough). Conflating admin and user119 produces lockouts (users disable the key) or over-permission (admins120 decrypt production data).1213. **Root account break-glass** — every CMK key policy MUST include account122 root with `kms:*`. Without this, an accidental policy lockout is123 unrecoverable — AWS support cannot restore access.1244. **Aliases after key creation** — human-readable names (`alias/<name>`)125 that decouple the application reference from the underlying key material126 (useful for rotation cutover).1275. **Automatic rotation** — symmetric CMKs support annual rotation (key128 material only, ARN/ID unchanged). Asymmetric, HMAC, and multi-Region129 primaries do NOT support auto-rotation.1306. **Multi-Region keys** — primary + replicas share key material but have131 independent key policies. Create primary first, then replicate. Cannot132 auto-rotate.1337. **Deletion window** — 7-30 day mandatory waiting period before irreversible134 deletion. Set to 30 days for production to allow recovery from accidents.135136## Prerequisites (verify before deployment)137138| Prerequisite | Why it matters | How to verify |139|---|---|---|140| **AWS account root access or break-glass** | Every CMK policy MUST include root. | `aws sts get-caller-identity` |141| **Key administrator principal** | IAM role/user that can administer the key. | `aws iam get-role --role-name <admin-role>` |142| **Key user principals** | Application roles needing Encrypt/Decrypt/GenerateDataKey. | `aws iam get-role --role-name <app-role>` |143| **CloudHSM cluster** (if custom key store) | Must be ACTIVE with >= 2 HSMs across AZs. | `aws cloudhsmv2 describe-clusters` |144| **Cross-account caller IAM** (if cross-account) | Caller IAM must ALSO grant KMS actions. | `aws iam get-role` in caller account |145| **Alias name uniqueness** | Unique within account/Region. `alias/aws/*` reserved. | `aws kms list-aliases` |146| **IAM permissions** | Caller needs `kms:CreateKey`, `iam:PutRolePolicy`, `kms:CreateAlias`. | `aws sts get-caller-identity` |147148## Deployment procedure (apply in order)149150### Step 1: Key spec + key usage selection151152**Symmetric (the common case):**153154| KeySpec | KeyUsage | What it does |155|---|---|---|156| `SYMMETRIC_DEFAULT` | `ENCRYPT_DECRYPT` | AES-256-GCM. Default for 95% of workloads (EBS, S3, RDS, Lambda, Secrets Manager). |157158**Asymmetric / HMAC:**159160| KeySpec | KeyUsage | What it does |161|---|---|---|162| `RSA_2048` / `RSA_3072` / `RSA_4096` | `ENCRYPT_DECRYPT` | RSA encryption (public key downloadable) |163| `RSA_2048` / `RSA_3072` / `RSA_4096` | `SIGN_VERIFY` | RSA signing (code/document signing) |164| `ECC_NIST_P256` / `P384` / `P521` | `SIGN_VERIFY` | ECDSA signing (lower latency) |165| `ECC_NIST_P256` / `P384` | `KEY_AGREEMENT` | ECDH key agreement (mTLS) |166| `HMAC_256` | `GENERATE_VERIFY_MAC` | HMAC-SHA-256 (JWT, API tokens) |167168**Choose `SYMMETRIC_DEFAULT` unless you have a specific reason not to.**169It is the only spec supporting automatic rotation, AWS service integration,170and the cheapest.171172### Step 2: Key policy (separate administrators from users)173174The key policy is the ONLY way to grant CMK access — IAM cannot override a175key policy denial. A production key policy contains four statements:1761771. **Break-glass (root)** — `kms:*` on account root. Mandatory recovery path.1782. **Key administrators** — lifecycle actions only (`Create*`, `Put*`,179 `Disable*`, `ScheduleKeyDeletion`). NO Encrypt/Decrypt.1803. **Key users** — `Encrypt`, `Decrypt`, `ReEncrypt*`, `GenerateDataKey*`,181 `DescribeKey`.1824. **Grant creation** — allows AWS service integrations to create grants183 when `kms:GrantIsForAWSResource=true`.184185```json186{187 "Version": "2012-10-17",188 "Statement": [189 {190 "Sid": "Enable IAM User Permissions (break-glass)",191 "Effect": "Allow",192 "Principal": { "AWS": "arn:aws:iam::123456789012:root" },193 "Action": "kms:*", "Resource": "*"194 },195 {196 "Sid": "Allow access for Key Administrators",197 "Effect": "Allow",198 "Principal": { "AWS": "arn:aws:iam::123456789012:role/kms-admin" },199 "Action": ["kms:Create*","kms:Describe*","kms:Enable*","kms:List*",200 "kms:Put*","kms:Update*","kms:Revoke*","kms:Disable*","kms:Get*",201 "kms:Delete*","kms:ScheduleKeyDeletion","kms:CancelKeyDeletion",202 "kms:RotateKeyOnDemand"],203 "Resource": "*"204 },205 {206 "Sid": "Allow use of the key",207 "Effect": "Allow",208 "Principal": { "AWS": "arn:aws:iam::123456789012:role/payments-svc" },209 "Action": ["kms:Encrypt","kms:Decrypt","kms:ReEncrypt*",210 "kms:GenerateDataKey*","kms:DescribeKey"],211 "Resource": "*"212 },213 {214 "Sid": "Allow attachment of persistent resources",215 "Effect": "Allow",216 "Principal": { "AWS": "arn:aws:iam::123456789012:role/payments-svc" },217 "Action": ["kms:CreateGrant","kms:ListGrants","kms:RevokeGrant"],218 "Resource": "*",219 "Condition": { "Bool": { "kms:GrantIsForAWSResource": "true" } }220 }221 ]222}223```224225**NEVER grant `kms:*` to anyone but root.**226227### Step 3: Key administrators vs. key users (separation principle)228229| Capability | Key administrators | Key users |230|---|---|---|231| `kms:Create*`, `kms:Put*`, `kms:Update*` | YES | NO |232| `kms:Enable*`, `kms:Disable*` | YES | NO |233| `kms:ScheduleKeyDeletion`, `kms:CancelKeyDeletion` | YES | NO |234| `kms:Encrypt`, `kms:Decrypt`, `kms:GenerateDataKey*` | NO | YES |235| `kms:Describe*`, `kms:List*` | YES | YES (read-only) |236| `kms:CreateGrant` | NO | YES (with condition) |237238### Step 4: Grants vs. key policy239240- **Key policy** — persistent JSON on the key. Use for stable, long-term241 access (app roles, break-glass root, key admin role).242- **Grants** — temporary, programmatic permissions with constraints. Use243 for AWS service integrations (Lambda, EBS), temporary access (migration),244 tighter scoping (Encrypt only on specific encryption context).245246Grants are subject to the key policy and eventually consistent (~5s247propagation). Prefer key policy for human/long-term roles; grants for248service integrations and temporary access.249250```bash251aws kms create-grant \252 --key-id alias/payments-cmk \253 --grantee-principal arn:aws:iam::123456789012:role/migration-tool \254 --operations Decrypt \255 --constraints '{"EncryptionContextSubset": {"department": "finance"}}' \256 --retiring-principal arn:aws:iam::123456789012:role/kms-admin257```258259### Step 5: Aliases260261```bash262aws kms create-alias --alias-name alias/payments-cmk --target-key-id <key-id>263```264265- Prefix `alias/` mandatory. `alias/aws/*` reserved for AWS-managed keys.266- Can be updated to point at a different key (rotation cutover).267- Name after the workload (`alias/payments-cmk`), not generic (`alias/my-key`).268269### Step 6: Automatic rotation270271```bash272aws kms enable-key-rotation --key-id alias/payments-cmk273```274275- **Symmetric CMKs**: annual auto-rotation. ARN, ID, policy unchanged.276 Existing ciphertext remains decryptable.277- **Asymmetric / HMAC**: do NOT support auto-rotation. Manual rotation278 required (create new key, update alias, re-encrypt).279- **Multi-Region primaries**: cannot auto-rotate (would desync replicas).280- **Custom key store (CloudHSM)**: supports auto-rotation since 2023.281- **On-demand rotation (2024-2025)**: `kms:RotateKeyOnDemand` triggers282 immediate rotation for eligible symmetric keys.283284### Step 7: Multi-Region keys (primary + replicas)285286```bash287# Primary (multi-Region)288aws kms create-key --description "Payments CMK (primary)" \289 --origin AWS_KMS --multi-region --policy file://policy.json290291# Replica in us-west-2292aws kms replicate-key \293 --key-id arn:aws:kms:us-east-1:123456789012:key/<primary-key-id> \294 --replica-region us-west-2 --policy file://replica-policy.json295```296297Each replica shares key material with the primary but has an INDEPENDENT298key policy. Multi-Region keys CANNOT auto-rotate. Use for cross-Region DR,299global DynamoDB table encryption, cross-Region EBS snapshot restore.300301### Step 8: Custom key store (CloudHSM)302303For FIPS 140-2 Level 3 compliance or regulatory key custody:304305```bash306# 1. CloudHSM cluster must be ACTIVE with >= 2 HSMs307aws cloudhsmv2 describe-clusters308309# 2. Create custom key store linked to the CloudHSM cluster310aws kms create-custom-key-store \311 --custom-key-store-name payments-hsm-keystore \312 --cloud-hsm-cluster-id cluster-xxx \313 --trust-anchor certificate.pem \314 --key-store-admin-credentials <kmsuser-password> \315 --hsm-credentials <hsm-password>316317# 3. Connect the key store318aws kms connect-custom-key-store --custom-key-store-id cks-xxx319320# 4. Create key in the custom key store321aws kms create-key --custom-key-store-id cks-xxx \322 --description "Payments CMK (CloudHSM)" --policy file://policy.json323```324325Rules:326- `kmsuser` CU must be logged out before KMS connects.327- Cluster must have >= 2 active HSMs across different AZs.328- Supports `SYMMETRIC_DEFAULT`, `RSA_*`, `ECC_*`, `HMAC_256`.329- A disconnected key store blocks all Encrypt/Decrypt on its keys.330331### Step 9: Deletion window332333```bash334aws kms schedule-key-deletion --key-id alias/payments-cmk --pending-window-in-days 30335```336337- Window: 7-30 days. Default is 30 days. For production, ALWAYS set 30 days.338- Deletion is IRREVERSIBLE — once the window expires, the key material is339 destroyed and all ciphertext encrypted under the key becomes permanently340 unrecoverable.341- The key is in `PendingDeletion` state during the window. It can be342 cancelled with `CancelKeyDeletion`.343- During `PendingDeletion`, the key CANNOT be used for Encrypt or344 GenerateDataKey, but CAN be used for Decrypt (so existing data can be345 migrated to a new key).346347### Step 10: Tagging + verification348349```bash350aws kms tag-resource --key-id <key-id> \351 --tags '[{"TagKey":"Environment","TagValue":"production"}]'352aws kms describe-key --key-id alias/payments-cmk353aws kms get-key-rotation-status --key-id alias/payments-cmk354aws kms get-key-policy --key-id <key-id> --policy-name default355```356357## Envelope encryption and cross-account access358359**Envelope encryption:** KMS has a 4 KB payload limit. Use360`GenerateDataKey` to get a plaintext data key + encrypted data key, encrypt361payloads client-side (AWS Encryption SDK), store ciphertext + encrypted key.362Decrypt by calling `Decrypt` on the encrypted data key.363364```bash365aws kms generate-data-key --key-id alias/payments-cmk \366 --key-spec AES_256 \367 --encryption-context '{"department":"finance","app":"payments"}'368369aws kms decrypt --ciphertext-blob fileb://encrypted-data-key.bin \370 --encryption-context '{"department":"finance","app":"payments"}'371```372373The encryption context is authenticated AAD — MUST be identical on Encrypt374and Decrypt. Full reference in `references/key-policy-and-multiregion-guide.md`.375376**Cross-account access:** KMS is a "both-must-allow" service. Account A's377key policy must grant account B, AND account B's IAM must grant the KMS378actions. A missing key policy statement fails silently with379`AccessDeniedException`. Full reference in380`references/key-policy-and-multiregion-guide.md`.381382## Edge-case handling383384Edge-case quick list moved verbatim to385`references/key-policy-and-multiregion-guide.md` (load on demand).386387## Workload matrix388389| Workload | KeySpec | Rotation | Multi-Region | Origin | Notes |390|---|---|---|---|---|---|391| EBS / S3 / RDS / Lambda env vars | `SYMMETRIC_DEFAULT` | Annual | Optional | AWS_KMS | Default for AWS service integration |392| DynamoDB / Aurora / SQS / SNS | `SYMMETRIC_DEFAULT` | Annual | Optional | AWS_KMS | Use CMK for full control |393| Secrets Manager | `SYMMETRIC_DEFAULT` | Annual | No | AWS_KMS | One CMK per secret-class |394| Code signing (Signer) | `RSA_4096` SIGN_VERIFY | Manual | Optional | AWS_KMS | Cannot auto-rotate |395| JWT / API tokens | `HMAC_256` | Manual | Optional | AWS_KMS | Cannot auto-rotate |396| Cross-Region DR | `SYMMETRIC_DEFAULT` | Manual | YES | AWS_KMS | Replica per Region |397| FIPS / regulatory | `SYMMETRIC_DEFAULT` | Annual | No | CloudHSM | Custom key store |398| Document signing | `ECC_NIST_P384` SIGN_VERIFY | Manual | Optional | AWS_KMS | Lower latency than RSA |399400## Recent AWS features (2024-2026)4014022024-2026 feature details moved verbatim to403`references/advanced-patterns.md` (load on demand).404405## NEVER (top 5 — full list of 13 anti-patterns in references)406407- NEVER create a CMK without the account root as break-glass408 (`{"AWS": "arn:aws:iam::<account>:root"}` with `kms:*`). Without root,409 an accidental lockout is unrecoverable — AWS support cannot help.410- NEVER grant `kms:*` to any non-root principal. Use scoped statements for411 users (Encrypt/Decrypt/GenerateDataKey) vs administrators (Create*/Disable*).412- NEVER combine key administrator and key user into one role. Separation of413 duties: admins manage lifecycle, users access data — never both.414- NEVER skip automatic rotation on a `SYMMETRIC_DEFAULT` CMK. Annual rotation415 is free, invisible to callers, and limits blast radius of compromise.416- NEVER delete a CMK without confirming no ciphertext is encrypted under it.417 Audit CloudTrail for recent Encrypt/GenerateDataKey usage.418419## Expert heuristic — choosing key spec, administrators, and users420421- **Key spec** — default to `SYMMETRIC_DEFAULT`. Choose asymmetric only for422 public-key encryption, digital signatures verifiable outside AWS, or HMAC.423- **Administrators** — one `kms-admin` role per security team. Lifecycle424 actions only, NO `kms:Decrypt`.425- **Users** — one role per application. Never grant to broad groups like426 "Developers" — that lets engineers read production ciphertext.427- **Break-glass** — root always in the policy with `kms:*`. Not a violation428 of least privilege — it is the recovery path.429- **Rotation** — symmetric: on; asymmetric/HMAC: document manual procedure.430- **Multi-Region** — only when needed (cross-Region DR, global tables).431 Single-Region is the right default.432- **Encryption context** — always include identifying fields like433 `{"app":"payments","env":"prod"}`. Scopes grants, provides audit trail.434435## Pre-flight safety checks (run before any provisioning CLI)436437Pre-flight command listing moved verbatim to438`references/deployment-cli-commands.md` (load on demand).439440## Output format — MANDATORY literal labels441442When invoked with a key provisioning request, your ENTIRE response MUST443be the checklist block below. The labels are **case-sensitive all-caps444keywords** — write them EXACTLY as shown. Do NOT write a preamble. Start445with `KEY:` and stop after the `VERIFICATION_COMMANDS:` block.446447```text448KEY: <alias-or-key-id>449VERDICT: READY_TO_DEPLOY | PREREQUISITES_MISSING450CHECKLIST:451 [✓] Key spec — <SYMMETRIC_DEFAULT | RSA_4096 | HMAC_256 | ...>452 [✓] Key usage — <ENCRYPT_DECRYPT | SIGN_VERIFY | GENERATE_VERIFY_MAC | KEY_AGREEMENT>453 [✓] Origin — <AWS_KMS | AWS_CLOUDHSM | EXTERNAL_KEY_STORE>454 [✓] Key administrators — <admin-role-arn> (lifecycle actions only, no Encrypt/Decrypt)455 [✓] Key users — <app-role-arns> (Encrypt, Decrypt, GenerateDataKey)456 [✓] Root account break-glass — arn:aws:iam::<account>:root (kms:*)457 [✓] Automatic rotation — <enabled annual | not supported for this spec>458 [✓] Alias — alias/<name>459 [✓] Deletion window — <7-30 days>460 [✓] Tags — <key=value pairs>461 [OPTIONAL] Multi-Region — <primary only | primary + replicas in <regions>>462 [OPTIONAL] Grants — <none | service integrations>463VERIFICATION_COMMANDS:464 aws kms describe-key --key-id alias/<name>465 aws kms get-key-rotation-status --key-id alias/<name>466 aws kms get-key-policy --key-id <key-id> --policy-name default467 aws kms list-aliases --key-id <key-id>468 aws kms list-resource-tags --key-id <key-id>469 aws kms list-grants --key-id <key-id>470```471472**Status marker semantics:**473- `[✓]` — applied and verified.474- `[✗]` — NOT applied or misconfigured. Cite the gap.475- `[OPTIONAL]` — recommended but not required for the workload type.476- `[INPUT NEEDED]` — prerequisite value missing; operator must provide.477478**PREREQUISITES_MISSING verdict:** if any REQUIRED prerequisite is missing479(administrator role ARN, application role ARN, CloudHSM cluster), the480verdict is `PREREQUISITES_MISSING` with each gap listed.481482## References (load on demand)483484- [`references/deployment-cli-commands.md`](references/deployment-cli-commands.md) — full copy-pasteable CLI sequence for all 10 provisioning steps, Terraform/CloudFormation equivalents, pre-flight safety checks.485- [`references/key-policy-and-multiregion-guide.md`](references/key-policy-and-multiregion-guide.md) — key policy structure, grants, multi-Region, CloudHSM, envelope encryption, cross-account, edge-case handling.486- [`references/advanced-patterns.md`](references/advanced-patterns.md) — recent AWS features 2024-2026 (on-demand rotation, HMAC GA, ECDH, XKS, VPC endpoint policies).487488## Domain489490AWS CloudOps / KMS Cryptographic Key Provisioning.491492## AWS documentation493494- **AWS KMS Developer Guide** — https://docs.aws.amazon.com/kms/latest/developerguide/overview.html495- **KMS Key Policies** — https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html496- **KMS Key Spec** — https://docs.aws.amazon.com/kms/latest/developerguide/kms-developer-guide.html#concepts497- **KMS Rotating Keys** — https://docs.aws.amazon.com/kms/latest/developerguide/rotate-keys.html498- **KMS Multi-Region Keys** — https://docs.aws.amazon.com/kms/latest/developerguide/multi-region-keys-overview.html499- **KMS Custom Key Store** — https://docs.aws.amazon.com/kms/latest/developerguide/custom-key-store-overview.html500- **KMS Grants** — https://docs.aws.amazon.com/kms/latest/developerguide/grants.html501- **Envelope Encryption** — https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#enveloping502- **KMS CLI Reference** — https://docs.aws.amazon.com/cli/latest/reference/kms/503504## References505506- `references/deployment-cli-commands.md` — full copy-pasteable CLI command507 sequence for all 10 provisioning steps, including Terraform equivalents.508509- `references/key-policy-and-multiregion-guide.md` — deep reference on key510 policy structure, multi-Region internals, CloudHSM lifecycle, envelope511 encryption, cross-account access, full NEVER list, and edge-case handling.