How Amazon EBS encryption works
You can encrypt both the boot and data volumes of an EC2 instance.
When you create an encrypted EBS volume and attach it to a supported instance type, the following types of data are encrypted:
-
Data at rest inside the volume
-
All data moving between the volume and the instance
-
All snapshots created from the volume
-
All volumes created from those snapshots
Amazon EBS encrypts your volume with a data key
using industry-standard AES-256 data encryption. The data key is generated by AWS KMS and then encrypted
by AWS KMS with a AWS KMS key prior to being stored with your volume information. Amazon EBS automatically
creates a unique AWS managed key in each Region where you create Amazon EBS resources. The
alias for the KMS key is aws/ebs
.
By default, Amazon EBS uses this KMS key for encryption. Alternatively, you can use a symmetric
customer managed encryption key that you create. Using your own KMS key gives you more flexibility,
including the ability to create, rotate, and disable KMS keys.
Amazon EC2 works with AWS KMS to encrypt and decrypt your EBS volumes in slightly different ways depending on whether the snapshot from which you create an encrypted volume is encrypted or unencrypted.
How EBS encryption works when the snapshot is encrypted
When you create an encrypted volume from an encrypted snapshot that you own, Amazon EC2 works with AWS KMS to encrypt and decrypt your EBS volumes as follows:
-
Amazon EC2 sends a GenerateDataKeyWithoutPlaintext request to AWS KMS, specifying the KMS key that you chose for volume encryption.
-
If the volume is encrypted using the same KMS key as the snapshot, AWS KMS uses the same data key as the snapshot and encrypts it under that same KMS key. If the volume is encrypted using a different KMS key, AWS KMS generates a new data key and encrypts it under the KMS key that you specified. The encrypted data key is sent to Amazon EBS to be stored with the volume metadata.
-
When you attach the encrypted volume to an instance, Amazon EC2 sends a CreateGrant request to AWS KMS so that it can decrypt the data key.
-
AWS KMS decrypts the encrypted data key and sends the decrypted data key to Amazon EC2.
-
Amazon EC2 uses the plaintext data key in the Nitro hardware to encrypt disk I/O to the volume. The plaintext data key persists in memory as long as the volume is attached to the instance.
How EBS encryption works when the snapshot is unencrypted
When you create an encrypted volume from unencrypted snapshot, Amazon EC2 works with AWS KMS to encrypt and decrypt your EBS volumes as follows:
-
Amazon EC2 sends a CreateGrant request to AWS KMS, so that it can encrypt the volume that is created from the snapshot.
-
Amazon EC2 sends a GenerateDataKeyWithoutPlaintext request to AWS KMS, specifying the KMS key that you chose for volume encryption.
-
AWS KMS generates a new data key, encrypts it under the KMS key that you chose for volume encryption, and sends the encrypted data key to Amazon EBS to be stored with the volume metadata.
-
Amazon EC2 sends a Decrypt request to AWS KMS to decrypt the encrypted data key, which it then uses to encrypt the volume data.
-
When you attach the encrypted volume to an instance, Amazon EC2 sends a CreateGrant request to AWS KMS, so that it can decrypt the data key.
-
When you attach the encrypted volume to an instance, Amazon EC2 sends a Decrypt request to AWS KMS, specifying the encrypted data key.
-
AWS KMS decrypts the encrypted data key and sends the decrypted data key to Amazon EC2.
-
Amazon EC2 uses the plaintext data key in the Nitro hardware to encrypt disk I/O to the volume. The plaintext data key persists in memory as long as the volume is attached to the instance.
For more information, see How Amazon Elastic Block Store (Amazon EBS) uses AWS KMS and Amazon EC2 example two in the AWS Key Management Service Developer Guide.
How unusable KMS keys affect data keys
When a KMS key becomes unusable, the effect is almost immediate (subject to eventual consistency). The key state of the KMS key changes to reflect its new condition, and all requests to use the KMS key in cryptographic operations fail.
When you perform an action that makes the KMS key unusable, there is no immediate effect on the EC2 instance or the attached EBS volumes. Amazon EC2 uses the data key, not the KMS key, to encrypt all disk I/O while the volume is attached to the instance.
However, when the encrypted EBS volume is detached from the EC2 instance, Amazon EBS removes the data key from the Nitro hardware. The next time the encrypted EBS volume is attached to an EC2 instance, the attachment fails, because Amazon EBS cannot use the KMS key to decrypt the volume's encrypted data key. To use the EBS volume again, you must make the KMS key usable again.
Tip
If you no longer want access to data stored in an EBS volume encrypted with a data key generated from a KMS key that you intend to make unusable, we recommend that you detach the EBS volume from the EC2 instance before you make the KMS key unusable.
For more information, see How unusable KMS keys affect data keys in the AWS Key Management Service Developer Guide.