Keeping data and applications safe in the cloud is one of the most visible challenges facing cloud teams in 2020. Cloud storage services where data resides are frequently a target for hackers, not because the services are inherently weak but because they are often improperly configured.
Encryption—to protect data at rest and in-flight—should be an organization’s number-one priority when using any storage service. On AWS, its Elastic Block Store (EBS) service provides persistent block-level storage volumes for Amazon EC2 instances. EBS volumes can be attached to your instances and primarily used for data that is rapidly changing or that requires specific input/output operations per second, (IOPS). Because they provide persistent level storage to your instances, EBS volumes are ideally suited for retaining important data and can be used to store personally identifiable information (PII). In any environment where this is the case, it’s essential that data on the volume is encrypted to protect it from malicious activity.
AWS makes encryption easy. In this article, we’ll step through three processes using AWS Elastic Block Store to help you make sure that your encryption is configured correctly. When you’re ready to get some hands-on experience creating an EC2 instance with additional EBS volume in a real AWS environment, check out Managing Instance Volumes Using EBS. During this hands-on lab, you will learn to attach and detach an EBS to/from a specific EC2 instance, take a snapshot, and master how to delete a volume.
With the EBS encryption mechanism, you don’t have to worry about managing keys to perform encryption yourself—it’s all managed and implemented by EBS. However, there are a couple of different ways that encryption can be applied depending on how and when you are creating your new EBS volumes. I will walk you through each process.
Let’s start with the behind-the-scenes basics. The EBS service interacts with another AWS service, the Key Management Service (KMS) to perform encryption. KMS uses Customer Master Keys (CMK) to create Data Encryption Keys (DEK), which enables data encryption across EBS and a range of AWS services.
When a volume is defined as an encrypted volume, EBS sends a request to KMS asking for a Data Encryption Key. The DEK is generated AND encrypted by the Customer Master Key, which by default will be a unique, regional CMK provided by AWS unless otherwise specified. The encrypted DEK is then stored with the metadata on the EBS volume.
It’s important to point out that no data has been encrypted up to this point. So far only the Data Encryption Key has been encrypted. The data encryption process is driven from the EC2 instance, not the EBS volume, so your data will be encrypted when it is connected to an associated EC2 instance.
When the volume is attached to an EC2 instance, the instance sends a ‘decrypt’ request to KMS along with the encrypted DEK from the EBS volume. KMS then responds with a plaintext version of the DEK. EC2 will store this within its hypervisor memory, allowing the instance itself to perform encryption on any read/writes to the EBS volume using the plaintext version of the DEK.
The DEK uses the AES-256 (Advanced Encryption Standard – 256 bit) algorithm to encrypt any data written. The process is managed from the EC2 instance, which ensures that the data is also encrypted when in transit to the EBS volume.
Let’s look at the full process:
Once your volume has been created, all data saved to this volume will be encrypted when attached to an EC2 instance.
The EBS volume attached to that instance will now be encrypted. It’s also worth noting that any snapshots created from these encrypted volumes (and any volumes created from these snapshots) will also be encrypted.
An existing unencrypted volume and the data it contains may not be encrypted. Instead, you’ll need to follow another process, outlined below.
1. Select your unencrypted volume
2. Select ‘Actions’ – ‘Create Snapshot’
3. When the snapshot is complete, select ‘Snapshots’ under ‘Elastic Block Store’ Select your newly created snapshot
4. Select ‘Actions’ – ‘Copy’
5. Check the box for ‘Encryption’
6. Select the CMK for KMS to use as required
7. Click ‘Copy’
8. Select the newly created snapshot
9. Select ‘Actions’ – ‘Create Volume’
10. You will notice that the normal ‘Encryption’ option is set to ‘True.’ Because the snapshot is itself encrypted, this cannot be modified. The volume now created from this snapshot will be encrypted
AWS has also introduced a feature that works to allow users (and of particular value to admins) to automatically enable encryption on all EBS volumes created within a specific region. Note: this is wide-reaching, but it only works on a per-region basis, so the decision to opt-in to default encryption will need to be enabled in all regions individually.
The advantages of this feature are:
The steps to opt-into default encryption are:
Although all EBS volume types support encryption, not all instance types are supported.
The following AWS instance types are supported for EBS encryption:
Instance Family | Instance types that support AWS EBS encryption |
General purpose | A1 | M3 | M4 | M5 | M5a | M5ad | M5d | M5dn | M5n | T2 | T3 | T3a |
Compute optimized | C3 | C4 | C5 | C5d | C5n |
Memory optimized | cr1.8xlarge | R3 | R4 | R5 | R5a | R5ad | R5d | R5dn | R5n | u-6tb1.metal | u-9tb1.metal | u-12tb1.metal | u-18tb1.metal | u-24tb1.metal | X1 | X1e | z1d |
Storage optimized | D2 | h1.2xlarge | h1.4xlarge | I2 | I3 | I3en |
Accelerated computing | F1 | G2 | G3 | G4 | Inf1 | P2 | P3 |
Be sure to consult the official AWS documentation to stay up to date with the supported instance types.
Now that you understand how your sensitive data can be protected through EBS encryption, you’ll want to learn more about encryption for other AWS services such as Encryption in S3, KMS, Redshift, and CloudHSM.
You can get started with these courses from the Cloud Academy Training Library:
It's Flash Sale time! Get 50% off your first year with Cloud Academy: all access to AWS, Azure, and Cloud…
In this blog post, we're going to answer some questions you might have about the new AWS Certified Data Engineer…
This is my 3rd and final post of this series ‘Navigating the Vocabulary of Gen AI’. If you would like…