Lesson 5 of 6 Data Security

Encrypting Data at Rest and in Transit

This lesson explains how data services integrate with AWS KMS for encryption at rest and with TLS for encryption in transit, protecting data if storage media, backups or network traffic are exposed.

Learning outcomes

After completing this lesson, you will be able to:

  • Choose between SSE-S3 and SSE-KMS.
  • Grant the permissions needed to read encrypted data across accounts.
  • Enforce encryption in transit.

Encryption at rest with KMS

Every data service can encrypt stored data with AWS KMS. Amazon S3 encrypts all new objects with SSE-S3 by default; SSE-KMS uses KMS keys instead, giving control over who can decrypt and an audit trail. S3 Bucket Keys reduce the number of KMS requests, and so the cost, for buckets with many objects.

AWS Glue uses security configurations to encrypt job output in S3, CloudWatch logs and job bookmarks, and encrypts the Data Catalog separately. Amazon EMR security configurations encrypt EBS volumes, local disks and data written through EMRFS. Redshift, Kinesis, DynamoDB, Athena query results, MWAA and SageMaker all support KMS encryption too. The following table summarises the options.

ServiceEncryption
S3SSE-S3 by default; SSE-KMS, with S3 Bucket Keys to cut KMS request costs
GlueSecurity configurations encrypt S3 output, CloudWatch logs and job bookmarks; Data Catalog encryption
EMRSecurity configurations for EBS, local disks and EMRFS
OthersRedshift, Kinesis, DynamoDB, Athena results, MWAA, SageMaker

Customer managed keys give you control of key policies, rotation and auditing.

True or false

Encryption at rest

Exam skills 4.3.2

Decide whether each statement about encryption at rest is true.

Log in to try this activity Interactive activities are free with an account.

Cross-account encrypted data

Reading data encrypted with SSE-KMS from another account requires permissions on both sides, because decrypting needs access to the KMS key as well as to the object. In the owning account, the KMS key policy must allow the other account's role to use the key. In the other account, IAM policies must allow that role to call kms:Decrypt and to read the S3 objects, and the bucket policy must allow the access too.

If any of these is missing, the request fails with access denied, which is a common cause of cross-account pipeline failures. AWS managed keys, such as aws/s3, cannot be shared across accounts at all, so data that will be read by other accounts must be encrypted with a customer managed key.

The following diagram shows the three permissions an analytics account needs to read an SSE-KMS bucket in a data lake account, and the account that grants each.

The three permissions an analytics account needs to read an SSE-KMS bucket in the data lake account. The bucket policy and the key policy in the data lake account must allow the analytics role, and an IAM policy in the analytics account must allow that role to read the bucket and use the key. Missing the key policy is the usual cause of AccessDenied; an AWS managed key cannot be shared at all.
All three are required; any one missing causes AccessDenied.
Troubleshooting

Cross-account access denied

Exam skills 4.3.3

Find the missing permission for reading SSE-KMS data across accounts.

Log in to try this activity Interactive activities are free with an account.

Encryption in transit

Data must also be protected while it moves between services. TLS should be used everywhere: Amazon Redshift's require_ssl parameter rejects unencrypted client connections, and Amazon EMR security configurations enable in-transit encryption between cluster nodes. For Amazon S3, bucket policies deny any request where aws:SecureTransport is false, so data can be read and written only over HTTPS.

When data must be protected even from the storage service, for example because of strict regulatory requirements, client-side encryption with the AWS Encryption SDK encrypts data before it leaves the producer, so it is stored and transferred only in encrypted form.

Match the pairs

Encryption in transit

Exam skills 4.3.4

Match each requirement with the control.

Log in to try this activity Interactive activities are free with an account.
Worked example

Sharing encrypted data with another account

An analytics account must read a curated bucket in the data lake account. The bucket uses SSE-KMS with a customer managed key. The following table lists the permissions required and where each is granted.

PermissionWhere
Bucket policy allowing the analytics account's role to readData lake account
Key policy allowing that role to use kms:DecryptData lake account
IAM policy allowing the role to read the bucket and use the keyAnalytics account

Missing the key policy is the usual cause of AccessDenied in this setup, even when the bucket policy is correct; an AWS managed key could not be used at all.

Check yourself

How can KMS request costs be reduced for an SSE-KMS bucket?

Show answer

By enabling S3 Bucket Keys.

Exam Tips

Remember for the exam

  • Cross-account SSE-KMS access needs a key policy that allows the account and an IAM policy that allows kms:Decrypt.
  • To encrypt Glue job outputs and logs, use a Glue security configuration.
  • To reduce KMS costs for SSE-KMS buckets, enable S3 Bucket Keys.
  • To require TLS for a bucket, deny requests where aws:SecureTransport is false.
  • AWS managed keys cannot be shared across accounts.