Skip to Content
Asterrr's Handbook
5 · Data protection

EBS encryption and lost KMS keys

How EBS uses KMS data keys and grants, encryption by default, snapshot rules, and what to do when the key is scheduled for deletion.

Exam tasks: 5.2.1 (choose KMS options and client- vs server-side encryption), 5.2.3 (lifecycle of data at rest)

The decision: which key does each copy of the volume (snapshot, AMI, restore) use, who can share it, and what breaks, and when, if that key becomes unusable?

EBS encryption happens on the host that runs the instance. It protects data at rest, snapshots, and data in transit between the instance and the volume. All EC2 instance types support it and you can attach encrypted and unencrypted volumes together.

attach volumeCreateGrant, Decryptencrypted I/OKey userEC2 instanceEncrypted volumeKMS key
On attach, EC2 uses a grant to have KMS unwrap the volume's data key. The plaintext key stays in hypervisor memory while the volume is attached.

Core facts

ItemFact
KeyA symmetric KMS key. The volume's data key is stored wrapped in the volume metadata
EncryptedData at rest, instance-to-volume traffic, all snapshots and every volume restored from them
Encryption by defaultAccount setting. New volumes and copies from unencrypted snapshots are always encrypted
Remove encryptionImpossible. Copies and restores of encrypted data stay encrypted
Encrypt existing unencrypted volumeSnapshot it, then create an encrypted volume. Or copy the snapshot with encryption on
Change the KMS keyNot on an existing volume or snapshot. Re-key with a snapshot copy
SharingPublic snapshots of encrypted volumes are not supported. Share with specific accounts and give them key access
AWS managed keyResources under it cannot be shared with other accounts. Use a customer managed key
Without key accessAn instance launched with a volume you cannot decrypt does not stay running
  • Encryption by default is a per-account, per-Region setting. Once on, every new volume and snapshot copy is encrypted with the default key (aws/ebs unless you choose a customer managed key). Turn it on in every Region you use, detect gaps with the Config rule ec2-ebs-encryption-by-default, and back it with an SCP that denies ec2:CreateVolume when ec2:Encrypted is false.
  • Encryption covers data at rest, data moving between the instance and the volume, snapshots and volumes created from them. It happens in Nitro hardware with no performance cost.
  • A volume created from an encrypted snapshot is always encrypted. You can change the key when you copy a snapshot or create a volume from it.

Encrypting what already exists, for EBS and the other storage services, is compared on RDS, DynamoDB, EFS and FSx encryption.

Exam signal

"Encrypt an existing unencrypted EBS volume" means snapshot, copy with encryption, create volume. "Enforce encryption for every new volume" means EBS encryption by default (plus an SCP or Config rule for detection).

Sharing snapshots and AMIs

Snapshot encrypted withCan share with another account?
UnencryptedYes, or even publicly (risky)
aws/ebs (AWS managed key)No, because you can't give another account access to that key
Customer managed keyYes: share the snapshot and allow the other account in the key policy
  • The receiving account should copy the shared snapshot with its own key, so it no longer depends on your key.
  • Encrypted snapshots can never be made public. Turn on block public access for EBS snapshots and for AMIs at account level to stop accidental public sharing of unencrypted ones.

Re-sharing with the default key

Copying a snapshot "to share it" while leaving the default aws/ebs key selected produces a snapshot that still can't be shared. The copy must use a customer managed key whose policy includes the target account.

Exam trap

You cannot enable encryption in place on a volume. And you cannot decrypt a snapshot copy back to unencrypted.

When the key becomes unusable

KMS keys become unusable when disabled, scheduled for deletion, when imported material expires or is deleted, or when a custom key store disconnects. Services feel it at different times.

ServiceImmediate effectLater effectRecovery
EBSNone: the data key is already in the Nitro hardware of the attached instanceDetach, stop or reattach failsMake the key usable again, then attach
S3 SSE-KMSNew GETs and PUTs fail with AccessDenied / KMS errorsSameRe-enable the key
RDS / AuroraInstance moves to inaccessible-encryption-credentials-recoverable after about 2 hoursAfter 7 days it becomes terminal; only a restore from backup helpsRe-enable the key and start the instance within 7 days
DynamoDB (customer managed key)Table status becomes INACCESSIBLE_ENCRYPTION_CREDENTIALSAfter 7 days, DynamoDB archives the table and takes an on-demand backup; global table replicas drop out after about 20 hoursRestore key access within 7 days, or re-enable the key and restore from the archival backup
Deleted key (any service)PermanentPermanentNone. Ciphertext is gone

Exam signal

"The KMS key was accidentally disabled" is recoverable: re-enable it. "The key was scheduled for deletion" is recoverable within the waiting period: cancel deletion, then re-enable. "The imported key material was deleted" is recoverable by importing the same material. "The key was deleted" is not recoverable.

Key deleted or scheduled for deletion

  1. If the key is Pending deletion, cancel the deletion. This is the clean fix.
  2. If the volume is still attached, the plaintext data key is held in memory. Create a new encrypted volume with a usable key, attach it to the same instance and copy the data across.
  3. Once the key is deleted, detached volumes and snapshots under it cannot be decrypted. There is no recovery.

Prevent this with a CloudWatch alarm or EventBridge rule on ScheduleKeyDeletion, and by disabling instead of deleting.

Scenarios

Scenario
A logistics company wants to share EBS snapshots of an analytics server with its auditor's AWS account. The snapshots are encrypted with the default aws/ebs key. What must the company do so the auditor can create volumes from them?
Scenario
An employee disabled a customer managed KMS key that protects an EBS data volume on a running EC2 instance and an S3 bucket used by the same application. Users report that downloads from the bucket fail, but the instance still reads and writes its data volume. What explains the behaviour?

Further reading

On this page