Data encryption is an effective solution to bolster data security. You can make sure that only authorized users or applications read your sensitive data by encrypting your data and managing access to the encryption key. One of the main reasons that customers from regulated industries such as healthcare and finance choose Amazon EMR is because it provides them with a compliant environment to store and access data securely.
This post provides a detailed walkthrough of two new encryption options to help you secure your EMR cluster that handles sensitive data. The first option is native EBS encryption to encrypt volumes attached to EMR clusters. The second option is an Amazon S3 encryption that allows you to use different encryption modes and customer master keys (CMKs) for individual S3 buckets with Amazon EMR.
Local disk encryption on Amazon EMR
Previously you could only choose Linux Unified Key Setup (LUKS) for at-rest encryption. You now have a choice of using LUKS or native EBS encryption to encrypt EBS volumes attached to an EMR cluster. EBS encryption provides the following benefits:
- End-to-end encryption – When you enable EBS encryption for Amazon EMR, all data on EBS volumes, including intermediate disk spills from applications and Disk I/O between the nodes and EBS volumes, are encrypted. The snapshots that you take of an encrypted EBS volume are also encrypted and you can move them between AWS Regions as needed.
- Amazon EMR root volumes encryption – There is no need to create a custom Amazon Linux Image for encrypting root volumes.
- Easy auditing for encryption – When you use LUKS encryption, though your EBS volumes are encrypted along with any instance store volumes, you still see EBS with Not Encrypted status when you use an Amazon EC2 API or the EC2 console to check on the encryption status. This is because the API doesn’t look into the EMR cluster to check the disk status; your auditors would need to SSH into the cluster to check for disk encrypted compliance. However, with EBS encryption, you can check the encryptions status from the EC2 console or through an EC2 API call.
- Transparent Encryption – EBS encryption is transparent to any applications running on Amazon EMR and doesn’t require you to modify any code.
Amazon EBS encryption integrates with AWS KMS to provide the encryption keys that protect your data. To use this feature, you have to use a CMK in your account and Region. A CMK gives you control to create and manage the key, including enabling and disabling the key, controlling access, rotating the key, and deleting it. For more information, see Customer Master Keys.
Enabling EBS encryption on Amazon EMR
To enable EBS encryption on Amazon EMR, complete the following steps:
- Create your CMK in AWS KMS.
You can do this either through the AWS KMS console, AWS CLI, or the AWS KMS CreateKey API. Create keys in the same Region as your EMR cluster. For more information, see Creating Keys.
- Give the Amazon EMR service role and EC2 instance profile permission to use your CMK on your behalf.
If you are using the
EMR_DefaultRole, add the policy with the following steps:
- Open the AWS KMS console.
- Choose your AWS Region.
- Choose the key ID or alias of the CMK you created.
- On the key details page, under Key Users, choose Add.
- Choose the Amazon EMR service role.The name of the default role is
- Choose Attach.
- Choose the Amazon EC2 instance profile.The name of the default role for the instance profile is
- Choose Attach.
If you are using a customized policy, add the following code to the service role to allow Amazon EMR to create and use the CMK, with the resource being the CMK ARN:
- Create and configure the Amazon EMR Security configuration template.Do this either through the console or using CLI or SDK, with the following steps:
- Open the Amazon EMR console.
- Choose Security Configuration.
- Under Local disk encryption, choose Enable at-rest encryption for local disks
- For Key provider type, choose AWS KMS.
- For AWS KMS customer master key, choose the key ARN of your CMK.This post uses the key ARN
- Select Encrypt EBS volumes with EBS encryption.
Default encryption with EC2 vs. Amazon EMR EBS encryption
EC2 has a similar feature called default encryption. With this feature, all EBS volumes in your account are encrypted without exception using a single CMK that you specify per Region. With EBS encryption from Amazon EMR, you can use different a KMS key per EMR cluster to secure your EBS volumes. You can use both EBS encryption provided by Amazon EMR and default encryption provided by EC2.
For this post, EBS encryption provided by Amazon EMR takes precedent, and you encrypt the EBS volumes attached to the cluster with the CMK that you selected in the security configuration.
Amazon S3 encryption also works with Amazon EMR File System (EMRFS) objects read from and written to S3. You can use either server-side encryption (SSE) or client-side encryption (CSE) mode to encrypt objects in S3 buckets. The following table summarizes the different encryption modes available for S3 encryption in Amazon EMR.
|Encryption location||Key storage||Key management|
|SSE-S3||Server side on S3||S3||S3|
|SSE-KMS||Server side on S3||KMS|
Choose the AWS managed CMK for Amazon S3 with the alias aws/s3, or create a custom CMK.
|CSE-KMS||Client side on the EMR cluster||KMS||A custom CMK that you create.|
|CSE-Custom||Client side on the EMR cluster||You||Your own key provider.|
The encryption choice you make depends on your specific workload requirements. Though SSE-S3 is the most straightforward option that allows you to fully delegate the encryption of S3 objects to Amazon S3 by selecting a check box, SSE-KMS or CSE-KMS are better options that give you granular control over CMKs in KMS by using policies. With AWS KMS, you can see when, where, and by whom your customer managed keys (CMK) were used, because AWS CloudTrail logs API calls for key access and key management. These logs provide you with full audit capabilities for your keys. For more information, see Encryption at Rest for EMRFS Data in Amazon S3.
Encrypting your S3 buckets with different encryption modes and keys
With S3 encryption on Amazon EMR, all the encryption modes use a single CMK by default to encrypt objects in S3. If you have highly sensitive content in specific S3 buckets, you may want to manage the encryption of these buckets separately by using different CMKs or encryption modes for individual buckets. You can accomplish this using the per bucket encryption overrides option in Amazon EMR. To do so, complete the following steps:
- Open the Amazon EMR console.
- Choose Security Configuration.
- Under S3 encryption, select Enable at-rest encryption for EMRFS data in Amazon S3.
- For Default encryption mode, choose your encryption mode.This post uses
- For AWS KMS customer master key, choose your key.The key you provide here encrypts all S3 buckets used with Amazon EMR. This post uses
- Choose Per bucket encryption overrides.You can set different encryption modes for different buckets.
- For S3 bucket, add your S3 bucket that you want to encrypt differently.
- For Encryption mode, choose an encryption mode.
- For Encryption materials, enter your CMK.
If you have already enabled default encryption for S3 buckets directly in Amazon S3, you can also choose to bypass the S3 encryption options in the security configuration setting in Amazon EMR. This allows Amazon EMR to delegate encrypting objects in the buckets to Amazon S3, which uses the encryption key specified in the bucket policy to encrypt objects before persisting it on S3.
This post walked through the native EBS and S3 encryption options available with Amazon EMR to encrypt and secure your data. Please share your feedback on how these optimizations benefit your real-world workloads.
About the Author
Duncan Chan is a software development engineer for Amazon EMR. He enjoys learning and working on big data technologies. When he is not working, he will be playing with his dogs.