KMS rotation and imported key material
Automatic, on-demand and manual rotation, rotation periods, and bring-your-own-key material compared with KMS-generated material.
Exam tasks: 5.3.2 (import and remove key material), 5.3.3 (AWS generated key material, imported versus AWS generated key material)
The decision: does the key material rotate itself, or do you import, expire and replace it yourself?
Rotation replaces the key material behind a KMS key. The key ID, ARN, aliases and policies stay the same. Old material is kept so old ciphertext still decrypts. Rotation does not re-encrypt data and does not rotate data keys.
Rotation options
| Option | Applies to | Detail |
|---|---|---|
| Automatic | Customer managed symmetric keys with KMS-generated material | Off by default. Default every 365 days. Custom period 90 to 2,560 days |
| On-demand | Same keys, plus symmetric keys with imported material (after you import new material) | Up to 25 times per key. Does not change the automatic schedule. Needs kms:RotateKeyOnDemand |
| Manual | Asymmetric, HMAC, custom key store keys, or any key you replace | Create a new key and repoint the alias with UpdateAlias |
| AWS managed keys | aws/<service> | Always on, about every 365 days. You cannot change it |
| AWS owned keys | Service internal | The service decides |
- Multi-Region keys with KMS-generated material rotate from the primary. The setting and the new material copy to every replica.
- While a key is disabled or Pending deletion, rotation pauses. If a rotation date was missed, KMS rotates right after it is re-enabled or deletion is cancelled.
- The condition key
kms:RotationPeriodInDayslets a key policy cap the period callers choose. - KMS writes a
RotateKeyevent to CloudTrail and an event to EventBridge when it rotates. - Manual rotation means a new key ID. Keep the old key enabled, or old ciphertext stops decrypting, and repoint aliases and applications.
- Rotation changes what new encryptions use. It never re-encrypts existing data and does not rotate data keys.
Legacy
Before May 2022, AWS managed keys rotated every three years and customer managed keys had a fixed one-year period with no on-demand option. Older guides still repeat this.
Generated vs imported
AWS generated (AWS_KMS) | Imported (EXTERNAL) | |
|---|---|---|
| Who creates the material | KMS HSMs | You, with your own entropy source |
| Key types | Symmetric, asymmetric, HMAC | Symmetric, asymmetric (except ML-DSA), HMAC |
| Automatic rotation | Yes (symmetric) | No |
| On-demand rotation | Yes | Yes, after you import new material (symmetric only) |
| Expiration | Never | Optional expiry date you choose |
| Remove material without deleting the key | Not possible | DeleteImportedKeyMaterial, effective at once |
| Waiting period to destroy | 7–30 days (delete the key) | None for the material; reimport restores it |
| Durability | AWS | You: lose your copy after it expires and the data is gone |
| Custom key stores | Supported | Not supported |
| Multi-Region | Material copied to replicas by KMS | You import the same material into each replica |
- Symmetric, asymmetric (not ML-DSA or ML-KEM) and HMAC keys can take imported material.
- Reasons to import are proving the entropy source, keeping a copy outside AWS, meeting a root-of-trust rule, or using expiry and instant removal.
- Reimport must use the same material. The ciphertext is bound to the KMS key, not only the material. If you delete the KMS key, importing the same material into a new key does not decrypt old data. Keep the key and remove only the material.
Exam signal
"We must be able to make the data unreadable immediately, and restore access later" means imported key material: delete the material now, reimport the same material later. Scheduling key deletion can't be undone after the waiting period, and disabling a key leaves the material inside AWS.
Exam signal
"Rotate with no operational work" means generated material with automatic rotation.
Exam trap
Rotation does not protect a leaked data key and does not re-encrypt existing objects. Asymmetric keys do not auto-rotate. The answer is a new key plus an alias update.
Imported key material (BYOK)
How import works
Create a key with no material. CreateKey with origin EXTERNAL. The key sits in PendingImport.
Download the wrapping public key and import token. GetParametersForImport returns an RSA public key and a
token that are valid for 24 hours.
Wrap your material. Encrypt it with the public key using RSAES-OAEP or RSA-AES key wrap, on your own HSM.
Import. ImportKeyMaterial with the token, the wrapped material and an optional expiration time.
- The ciphertext is bound to the KMS key, not just the material. If you delete the KMS key, importing the same material into a new key doesn't decrypt old data. Keep the key; only remove the material.
- Only the same material can be reimported into a key, unless you are staging new material for on-demand rotation.
- Set a CloudWatch alarm on the
SecondsUntilKeyMaterialExpirationmetric so an expiry doesn't surprise you. - When imported material expires or is deleted, the key becomes unusable. AWS services that cached a data key (an attached EBS volume, for example) keep working until the data key is needed again.
Rotating imported material
- Generate new material and import it into the same key. It shows as pending rotation.
- Call
RotateKeyOnDemand. New encryptions use the new material, and old ciphertext still decrypts with the old material, which stays attached to the key. - Every material version must stay present and unexpired. Losing any of them makes the whole key unusable.
Rotating BYOK the old way
Older material taught "create a new KMS key, import new material, move the alias" as the only way to rotate imported keys. That still works, but it leaves a second key to manage and applications that stored the key ARN break. On-demand rotation of imported material now keeps the same key ID.
Scenarios
KMS supports on-demand rotation of imported material: import new material into the same key, then rotate, and the ARN stays the same while old ciphertext still decrypts. Automatic rotation isn't available for imported material. A new key changes the ARN. Replacing material outright isn't allowed and would orphan existing ciphertext.
Related
Further reading
KMS key policy, IAM and grants
How KMS authorizes a request. Key policy, IAM policy and grants, the root principal statement, condition keys and encryption context.
AWS CloudHSM and KMS comparison
Single-tenant HSM clusters you control, when to pick CloudHSM over KMS, and the custom key stores (CloudHSM and external) that let AWS services use that key material.