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.
Core facts
| Item | Fact |
|---|---|
| Key | A symmetric KMS key. The volume's data key is stored wrapped in the volume metadata |
| Encrypted | Data at rest, instance-to-volume traffic, all snapshots and every volume restored from them |
| Encryption by default | Account setting. New volumes and copies from unencrypted snapshots are always encrypted |
| Remove encryption | Impossible. Copies and restores of encrypted data stay encrypted |
| Encrypt existing unencrypted volume | Snapshot it, then create an encrypted volume. Or copy the snapshot with encryption on |
| Change the KMS key | Not on an existing volume or snapshot. Re-key with a snapshot copy |
| Sharing | Public snapshots of encrypted volumes are not supported. Share with specific accounts and give them key access |
| AWS managed key | Resources under it cannot be shared with other accounts. Use a customer managed key |
| Without key access | An 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/ebsunless you choose a customer managed key). Turn it on in every Region you use, detect gaps with the Config ruleec2-ebs-encryption-by-default, and back it with an SCP that deniesec2:CreateVolumewhenec2:Encryptedis 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 with | Can share with another account? |
|---|---|
| Unencrypted | Yes, or even publicly (risky) |
aws/ebs (AWS managed key) | No, because you can't give another account access to that key |
| Customer managed key | Yes: 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.
| Service | Immediate effect | Later effect | Recovery |
|---|---|---|---|
| EBS | None: the data key is already in the Nitro hardware of the attached instance | Detach, stop or reattach fails | Make the key usable again, then attach |
| S3 SSE-KMS | New GETs and PUTs fail with AccessDenied / KMS errors | Same | Re-enable the key |
| RDS / Aurora | Instance moves to inaccessible-encryption-credentials-recoverable after about 2 hours | After 7 days it becomes terminal; only a restore from backup helps | Re-enable the key and start the instance within 7 days |
| DynamoDB (customer managed key) | Table status becomes INACCESSIBLE_ENCRYPTION_CREDENTIALS | After 7 days, DynamoDB archives the table and takes an on-demand backup; global table replicas drop out after about 20 hours | Restore key access within 7 days, or re-enable the key and restore from the archival backup |
| Deleted key (any service) | Permanent | Permanent | None. 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
- If the key is Pending deletion, cancel the deletion. This is the clean fix.
- 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.
- 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
The AWS managed key's policy can't be edited, so the snapshots must be re-encrypted under a customer managed key that the auditor's account may use. Encrypted snapshots can't be made public at all, and turning on encryption by default in the auditor's account doesn't grant access to the source key.
An attached EBS volume keeps working because the plaintext data key is already in the Nitro hardware. It will fail when the volume is detached or the instance stops. S3 calls KMS for each object and fails immediately. EBS uses the key you choose, KMS doesn't cache disabled keys, and permissions don't matter when the key itself is disabled.
Related
- KMS keys and envelope encryption
- KMS key policy, IAM and grants
- AWS Backup, DLM and DataSync
- RDS, DynamoDB, EFS and FSx encryption
Further reading
Protecting S3 buckets and data
Bucket policy controls, VPC endpoints, TLS enforcement, MFA conditions, versioning, Object Lock, lifecycle retention and data event logging.
RDS, DynamoDB, EFS and FSx encryption
Encryption at rest for RDS and Aurora, DynamoDB with the Database Encryption SDK, EFS and FSx, and which of them can be encrypted after creation.