Rotating KMS Keys Automatically and Manually
This lesson explains how key rotation replaces the cryptographic material behind a KMS key on a schedule, limiting how much data any one version of the key protects. How rotation works depends on the type of key.
Learning outcomes
After completing this lesson, you will be able to:
- Identify the rotation options available for each type of key.
- Explain why automatic rotation does not require data to be re-encrypted.
- Describe how keys that cannot rotate automatically are rotated manually through an alias.
Rotation options
How a key is rotated depends on its type. For a customer managed symmetric key, automatic rotation is optional and the customer chooses the period, between 90 and 2,560 days, with 365 days as the default; the key can also be rotated immediately on demand. AWS managed keys rotate automatically every year, and the schedule cannot be changed. AWS owned keys are rotated by AWS according to its own schedule.
Keys with imported key material do not support automatic rotation. Since June 2025, a symmetric key with imported material can be rotated on demand instead: new key material is imported into the same key and then made current, so the key ID and ARN stay the same. Asymmetric keys and HMAC keys support neither automatic nor on-demand rotation, and are rotated manually by creating a new key and pointing the application's alias at it, as described below. The following table summarises the options.
| Key type | Rotation |
|---|---|
| Customer managed symmetric | Automatic every 90 to 2,560 days (365 by default), and on demand |
| AWS managed | Automatic every year; cannot be changed |
| AWS owned | Managed by AWS |
| Symmetric with imported key material | On demand: import new key material into the same key, then rotate |
| Asymmetric or HMAC | Manual: create a new key and move the alias to it |
How is this key rotated?
How automatic rotation works
A KMS key is a logical resource with an ID, an ARN, aliases and a key policy. Behind it is the key material, the secret cryptographic bits that actually encrypt and decrypt data. Automatic rotation replaces only the key material. The key ID, ARN, aliases and policy stay the same, so applications and permissions need no changes.
KMS keeps every previous version of the key material for as long as the key exists. Each ciphertext records which version encrypted it, so data encrypted before a rotation still decrypts with the old material, and nothing needs to be re-encrypted. New encryption operations use the newest material automatically. Rotation therefore limits how much data any one version of the key material protects, without any work for applications.
Besides the scheduled rotation, a customer managed symmetric key can be rotated immediately on demand, up to 25 times per key, for example after a suspected exposure or to meet an audit requirement. The following commands enable rotation every 180 days, check the status and rotate immediately.
aws kms enable-key-rotation --key-id alias/app-data --rotation-period-in-days 180
aws kms get-key-rotation-status --key-id alias/app-data
aws kms rotate-key-on-demand --key-id alias/app-dataRotation periods
Manual rotation
Keys that cannot rotate in place, namely asymmetric keys and HMAC keys, are rotated by replacing the whole key. Because a new key has a new key ID, applications must find it through an alias, a friendly name such as alias/app-data that can be moved from one key to another. The procedure consists of the following steps.
-
Create a new key
Create a new KMS key with the same key spec and usage as the old one.
-
Move the alias
Point the application's alias at the new key with
aws kms update-alias. New encryptions through the alias now use the new key. -
Keep the old key enabled
Existing ciphertext can be decrypted only by the key that encrypted it.
-
Retire the old key (optional)
Re-encrypt old data under the new key with the
ReEncryptoperation, then disable the old key and later schedule its deletion.
Applications that refer to the key by alias switch to the new key without code changes, while applications that use the key ID or ARN directly must be updated. This is one reason to always reference keys by alias in application configuration.
Meeting a rotation policy
A compliance policy requires encryption keys to be rotated every six months. The team uses three kinds of key:
| Key | How it is rotated |
|---|---|
| Customer managed symmetric key for application data | Enable automatic rotation with a 180-day period |
| Key with imported material for a regulated workload | Every six months, import new key material into the same key and rotate it on demand |
AWS managed key aws/s3 | Rotates yearly and cannot be changed, so the bucket is switched to a customer managed key |
None of the existing data has to be re-encrypted: both automatic and on-demand rotation keep the earlier key material, so older ciphertext still decrypts.
After automatic rotation, can data encrypted before the rotation still be decrypted?
Show answer
Yes. KMS keeps all earlier key material and uses it automatically to decrypt older ciphertext, and the key ID and ARN do not change.
Exam Tips
Remember for the exam
- Rotation does not require re-encrypting data.
- Automatic rotation keeps the same key ID, so applications need no changes.
- Manual rotation means creating a new key and updating the alias to point at it.
- Imported, asymmetric and HMAC keys cannot rotate automatically; imported symmetric keys rotate on demand after new material is imported.
- AWS managed keys rotate every year and their rotation cannot be changed.