Cert EspressoLearn. Practise. Find your flow.

A LITTLE FOCUS.
A BIG NEXT STEP.

Your pace. Your space.
AWS · DEA-C01

Encryption and masking

DEA-C01 · Lesson 21 of 23 · 3:03:41

YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗

Learning with these videos? Subscribe for new courses and exam-style questions.

In this lesson

Prepare for the DEA-C01 exam (AWS Certified Data Engineer – Associate). In this lesson: masking, anonymization, and pseudonymization, Glue Detect PII, DataBrew masking, and Redshift dynamic data masking, AWS KMS envelope encryption and SSE-KMS, cross-account access to encrypted data with key policies and customer managed keys, and encryption in transit with aws:SecureTransport, require_ssl, and client-side encryption. Includes three original practice questions.

Study notes

The text of this lesson, to read at your own pace. Information as of November 2026.

Emails in plain text

AnyCompany Games shares match data with a partner, and the partner receives player email addresses in plain text. A bucket encrypted with an AWS managed key cannot be read by the analytics account, and an old tool still sends data to Redshift without TLS. This lesson covers masking and anonymization, KMS keys, encryption across accounts, and encryption in transit.

Masking and anonymization

Laws and company policies often require hiding personal data, or PII, such as names, email addresses, and card numbers, from people who do not need it. Masking hides part or all of a value, like showing only the last four digits, while anonymization removes the link to a person, for example by dropping or aggregating the columns that identify them. The Detect PII transform of AWS Glue finds PII in a dataset and can redact it, partially redact it, or replace it with a SHA-256 hash, and DataBrew recipes offer masking, hashing, encryption, and shuffling steps. A hash gives the same output for the same input, so tables can still be joined on it, but it is pseudonymization rather than anonymization: anyone who has the original value can compute its hash and find the match. In Redshift, dynamic data masking applies masking policies at query time, for chosen users or roles, without changing the stored data, and a priority decides between policies on the same column.

Encryption with KMS keys

AWS KMS creates and controls encryption keys, and KMS keys never leave the service unencrypted. For large data, KMS uses envelope encryption: it returns a data key both in plain text and encrypted, you encrypt the data with the plain key, delete it from memory, and store the encrypted data key with the data. To decrypt, you send the encrypted data key to KMS, which decrypts it with the KMS key, if your permissions allow it. S3 encrypts every new object by default with S3 managed keys, called SSE-S3, and SSE-KMS uses KMS keys instead, with control over who can use them and a CloudTrail log of each use. Redshift encrypts databases by default, Glue security configurations encrypt job outputs, logs, and bookmarks, and automatic rotation gives a customer managed key new key material every year.

Encryption across accounts

When another account must read encrypted data, it needs permission to use the key, not only the data. Every KMS key has exactly one key policy, and cross-account access requires two permissions: the key policy must allow the other account, and an IAM policy in that account must allow its users or roles to use the key. AWS managed keys can be used only in their own account, and their policies cannot be changed, so data for another account needs a customer managed key. For S3, the bucket policy must also allow the other account, so a cross-account read of SSE-KMS objects needs the bucket policy, the key policy, and the IAM policy of the reader. In the key policy, name the account or the exact roles of the other account, and allow only the actions they need, like decrypt for a reader.

In transit and before transit

Encryption in transit protects data on the network with TLS, and AWS service endpoints support it. For S3, a bucket policy can deny every request that does not use TLS, with the condition aws:SecureTransport set to false. Redshift accepts connections with or without SSL by default, so set the require_ssl parameter to true in the parameter group of the cluster or workgroup. Before transit, client-side encryption encrypts the data on your side, for example with the Amazon S3 Encryption Client, so S3 receives objects already encrypted and never sees them in plain text. Client-side and server-side encryption can be combined, because S3 sees client-side encrypted objects as ordinary objects.

Protection at AnyCompany Games

Here is the plan at AnyCompany Games: before sharing, a Glue job replaces player email addresses with SHA-256 hashes, and drops names and postal addresses. In Redshift, a masking policy shows support agents only the last four digits of phone numbers. Data lake buckets use SSE-KMS with a customer managed key, whose key policy allows the roles of the analytics account to decrypt. And every bucket policy denies requests without TLS, while Redshift requires SSL.

Recap

Let's recap. Masking hides values, anonymization removes the link to a person, and a hash is pseudonymization that still allows joins. Glue Detect PII and DataBrew mask data in pipelines, and Redshift dynamic data masking hides values at query time. KMS uses envelope encryption, and SSE-KMS adds key policies and a CloudTrail log of each use. Cross-account access needs the key policy, an IAM policy in the other account, and a customer managed key. And for transit, require TLS with aws:SecureTransport and require_ssl, or encrypt on the client before sending.

Quick checks for this lesson

The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.

  1. A Glue job writes game events to S3. The security team wants to control who can use the encryption key, and to see each use of the key in CloudTrail. Which default encryption should the bucket have?

    • SSE-S3, with keys that Amazon S3 manages for you
    • SSE-C, with keys that the job sends in each request
    • Dynamic data masking on the columns of the events
    • SSE-KMS, with a customer managed key in AWS KMS
    Show the answer

    SSE-KMS, with a customer managed key in AWS KMS

    With SSE-KMS and a customer managed key, the key policy controls who can use the key, and CloudTrail logs each use. “SSE-S3, with keys that Amazon S3 manages for you” would encrypt the data, but S3 manages those keys, with no key policy to control. “SSE-C, with keys that the job sends in each request” would leave the keys to the job, outside KMS, and S3 now blocks SSE-C on new buckets by default. And “Dynamic data masking on the columns of the events” would hide values at query time, without encrypting anything.

  2. The analytics account must read objects in a bucket of the data account. The objects use SSE-KMS with a customer managed key, and the bucket policy already allows the analytics account, but reads fail with access denied. What else is needed?

    • A switch of the objects to the AWS managed key for S3
    • Key policy and IAM permissions for the analytics account
    • A deny statement with aws:SecureTransport on the bucket
    • A Glue security configuration in the analytics account
    Show the answer

    Key policy and IAM permissions for the analytics account

    Cross-account access to a KMS key needs the key policy to allow the analytics account, and an IAM policy there to allow its roles. “A switch of the objects to the AWS managed key for S3” would make it worse, because an AWS managed key can be used only in its own account. “A deny statement with aws:SecureTransport on the bucket” would require TLS, without giving access to the key. And “A Glue security configuration in the analytics account” would encrypt the outputs of Glue, not grant access to this key.

  3. A mobile game uploads crash reports to S3. Company policy says that the reports must be encrypted before they leave the device, so that S3 never sees them in plain text. What should the data engineer use?

    • SSE-KMS as the default encryption of the bucket
    • A bucket policy that denies requests without TLS
    • Client-side encryption before each upload to S3
    • Dynamic data masking on the reports in Redshift
    Show the answer

    Client-side encryption before each upload to S3

    Client-side encryption encrypts the reports on the device, so S3 receives them already encrypted. “SSE-KMS as the default encryption of the bucket” would encrypt them only after they reach S3. “A bucket policy that denies requests without TLS” would protect the network, but S3 would still receive the reports in plain text. And “Dynamic data masking on the reports in Redshift” would hide values in query results, not encrypt files.