1.Envelope Encryption, KMS Keys, Policies, Grants, and Rotation
Envelope encryption uses two keys: a data key that encrypts your actual data, and a KMS key that encrypts (wraps) that data key. KMS never touches your bulk data directly — it only ever handles the small, wrapped data key. A key policy is the resource policy every KMS key must have, controlling who can use it. A grant hands out a narrow, temporary permission on a key without editing that key policy at all.
Key features
- Customer managed key: you create and fully control it — key policy, rotation, deletion, cross-account sharing. AWS managed key: exists in your account but AWS controls its policy, and it cannot be shared cross-account or used outside its one owning service
- A key policy is a resource policy attached to the KMS key itself — every KMS key must have exactly one, with no exceptions
- A grant allows a principal to use a key for specific operations without editing the key policy — commonly created and retired automatically by AWS services for temporary access
- Encryption context is a set of non-secret key-value pairs passed with an encrypt/decrypt call; KMS uses it as additional authenticated data, so decryption fails if the context does not match exactly what was supplied at encryption time
- Automatic key rotation on a customer managed key defaults to every 365 days and keeps all prior key material, so old ciphertext still decrypts correctly — an AWS managed key is always rotated automatically, every year, with no opt-out
- Cross-account key usage requires two separate grants of permission: the KMS key policy in the owning account must allow the other account's principal, and that principal's own account must separately grant it the matching kms: permission
The three KMS key types
- Key policy
- One per key, always required — the baseline authorization document
- Edited directly; changes apply to everyone the policy names
- The natural place for long-lived, broad access
- Grant
- Any number per key, all optional — layered on top of the key policy
- Created and retired independently, without touching the key policy
- The natural place for narrow, temporary, or automated access
Signature
Key policy (required, one per key) · Grant (optional, temporary, layered on top)
Envelope encryption: a data key encrypts your data, a KMS key encrypts the data key. Every key needs exactly one key policy; grants add temporary access without editing it. Encryption context is authenticated but not secret — it appears in CloudTrail. Customer managed keys support cross-account sharing and optional rotation (365-day default); AWS managed keys don't share cross-account and rotate automatically every year regardless.