Data Encryption and Masking on AWS: KMS, TLS, and Anonymization
On AWS, you protect data with three complementary controls: encryption at rest through AWS KMS, encryption in transit through TLS, and masking or anonymization for data that must stay useful but not identifiable. AWS KMS is the center of gravity — it issues and controls the keys that S3, Amazon Redshift, DynamoDB, and nearly every other data service use for envelope encryption, and its key policies decide who can decrypt, including principals in other AWS accounts. The DEA-C01 exam tests whether you can pick the right key type (AWS owned, AWS managed, or customer managed), share encrypted data across account boundaries, force TLS on every connection, and apply masking with Lake Formation data filters, Redshift dynamic data masking, or tokenization when compliance rules say raw PII must never reach an analyst. This lesson works through each control, the trade-offs between them, and the cross-account gotchas the exam loves.
On this page8 sections
- How AWS KMS envelope encryption works
- Choosing a KMS key type: AWS owned, AWS managed, or customer managed
- Key policies, IAM, and grants: who can use a key
- Encryption at rest across S3, Redshift, and DynamoDB
- Cross-account encryption: sharing KMS-encrypted data
- Encryption in transit and before transit
- Data masking and anonymization: filters, dynamic masking, and tokenization
- Choosing the right control: an exam decision pattern
- Explain envelope encryption and how AWS KMS data keys protect large datasets
- Choose between AWS owned, AWS managed, and customer managed KMS keys for a given requirement
- Configure cross-account access to KMS-encrypted data using key policies and grants
- Enforce encryption in transit with TLS and IAM condition keys across data services
- Apply masking and anonymization using Lake Formation data filters, Redshift dynamic data masking, and tokenization
- Identify which encryption options S3, Redshift, and DynamoDB support at rest
How AWS KMS envelope encryption works
AWS KMS protects data through envelope encryption: KMS never encrypts your gigabytes of data directly with the KMS key. Instead, a service calls the GenerateDataKey API, receives a unique data key in both plaintext and encrypted form, encrypts your object or block locally with the plaintext data key, then discards the plaintext key and stores the encrypted copy of the data key alongside the ciphertext. To decrypt, the service sends the encrypted data key back to KMS, which returns the plaintext data key so the data can be decrypted in memory.
This design matters for two exam-relevant reasons. First, the KMS key itself never leaves KMS unencrypted — access to it is always mediated by the key policy and IAM, and every use is logged to AWS CloudTrail. Second, performance and cost stay manageable: the bulk encryption happens locally with a symmetric data key, and KMS is only called once per object (or less, with features like S3 Bucket Keys, which let a bucket reuse a short-lived bucket-level key to cut KMS request volume and cost dramatically for high-object-count workloads).
Revoking access is equally elegant. If you disable a customer managed key or deny a principal kms:Decrypt, every piece of data whose data key was wrapped by that KMS key becomes unreadable to that principal — you do not have to re-encrypt anything to cut someone off. That is why exam scenarios about "immediately revoke access to encrypted data" almost always resolve to changing the KMS key policy or disabling the key, not to rewriting objects.
Choosing a KMS key type: AWS owned, AWS managed, or customer managed
Choose a customer managed key whenever a scenario demands control: you need to edit the key policy, share the key across accounts, disable or delete it on your schedule, or prove auditable control over rotation. Choose the AWS managed key (the ones named aws/s3, aws/redshift, and so on) when you just want KMS-backed encryption with CloudTrail visibility but no management burden. AWS owned keys are keys AWS uses on your behalf without showing them in your account at all — DynamoDB uses one by default.
| Capability | AWS owned key | AWS managed key | Customer managed key |
|---|---|---|---|
| Visible in your account | No | Yes (view only) | Yes |
| You control the key policy | No | No | Yes |
| Usable across AWS accounts | No | No | Yes |
| Rotation | Managed by AWS | Automatic, managed by AWS | Optional automatic rotation you enable, or manual |
| Can disable, delete, or add grants | No | No | Yes |
| Monthly key charge | No | No | Yes |
The single most tested distinction: an AWS managed key can never be used by another AWS account. If a scenario involves cross-account access to encrypted S3 objects, Redshift snapshots, or EBS volumes, the answer requires a customer managed key — full stop. If a stem says the team is currently using SSE-KMS with the aws/s3 key and now needs to share with a partner account, the first step is re-encrypting or reconfiguring with a customer managed key.
Customer managed keys also support imported key material (bring your own key) and multi-Region keys — related keys in different Regions that share key material and key ID, so data encrypted in one Region can be decrypted in another without a cross-Region KMS call. Multi-Region keys are the clean answer for encrypted cross-Region replication and disaster recovery scenarios.
Key policies, IAM, and grants: who can use a key
Access to a customer managed key is decided by the intersection of its key policy and IAM policies. The key policy is the primary, resource-based control — unlike most AWS resources, a KMS key does not implicitly trust even its own account: the default key policy contains a statement that delegates permission decisions to IAM by allowing the account root principal, and if you remove that statement, IAM policies alone can no longer grant access to the key.
Separate the two permission planes in your head. Key administrators get permissions like kms:PutKeyPolicy, kms:ScheduleKeyDeletion, and kms:EnableKey — they manage the key but should not necessarily be able to decrypt with it. Key users get kms:Encrypt, kms:Decrypt, kms:GenerateDataKey, and kms:DescribeKey. Exam answers that follow least privilege keep these roles distinct.
Grants are the third mechanism: temporary, programmatic permissions that AWS services use to act on your behalf. When Amazon Redshift or Amazon EBS needs to use your key for an asynchronous workflow, it creates a grant rather than requiring a key policy edit. You will also see the kms:ViaService condition key, which restricts a key so it can only be used through a specific service (for example, only via S3 in a given Region), and kms:EncryptionContext conditions, which bind a key operation to name-value pairs that must match at decrypt time — an integrity check that also shows up in CloudTrail logs for auditing.
Encryption at rest across S3, Redshift, and DynamoDB
Each major data store offers KMS integration, but the defaults and options differ, and the exam expects you to know which knob exists where.
Amazon S3 encrypts every new object by default with SSE-S3 (S3-managed AES-256 keys). Step up to SSE-KMS when you need key-level access control, CloudTrail logging of key usage, or cross-account sharing; enable S3 Bucket Keys with SSE-KMS to reduce KMS request costs on busy buckets. DSSE-KMS applies two independent layers of encryption for the strictest compliance regimes. SSE-C lets a client supply its own key with every request (S3 stores nothing), and client-side encryption — encrypting before upload, for example with the AWS Encryption SDK — means AWS never sees plaintext at all. You can require encryption on write with a bucket policy that denies PutObject requests lacking the expected s3 encryption header.
Amazon Redshift encryption is set at the cluster (or serverless namespace) level using KMS. Everything inside — data blocks, system metadata, and snapshots — is encrypted, and snapshots inherit the cluster's key. To share an encrypted snapshot with another account you must use a customer managed key and grant the other account access to it. DynamoDB is always encrypted at rest; your only choice is which key: the AWS owned key (default, free, invisible), the AWS managed aws/dynamodb key, or a customer managed key when auditors require key control. Backups and DynamoDB Streams data are covered as well.
Beyond the big three: AWS Glue can encrypt Data Catalog metadata, job bookmarks, and the S3 outputs its jobs write; Amazon EMR uses security configurations to encrypt EMRFS data in S3 and local disks on cluster nodes; and Amazon Kinesis Data Streams offers server-side encryption with KMS so records are encrypted before they land in the stream.
Cross-account encryption: sharing KMS-encrypted data
Configuring encryption across account boundaries always takes two grants, not one: the key policy in the producer account must allow the external account (or specific external principals) to use the key, and an IAM policy in the consumer account must grant its principals the matching kms:Decrypt or kms:GenerateDataKey permissions. Neither side alone is sufficient — a key policy that trusts account B does nothing until an admin in account B delegates that access onward with IAM. This double-gate is the most common cross-account wrong-answer trap.
Work through the canonical scenario: a central data lake account holds an S3 bucket encrypted with SSE-KMS under a customer managed key, and an analytics account must run Amazon Athena queries against it. You need three things: a bucket policy allowing the analytics account to read the objects, a key policy statement allowing the analytics account to decrypt with the key, and IAM permissions in the analytics account for both the bucket and the key. Miss the key policy and every GetObject fails with an access-denied error from KMS even though the S3 permissions look perfect.
S3 replication between accounts with KMS adds its own wrinkle: the replication role must be able to decrypt with the source key and encrypt with the destination key, and the destination bucket's key must permit the source account's replication role. For Redshift, sharing an encrypted snapshot cross-account requires granting the target account use of the customer managed key before authorizing the snapshot access. Whenever a scenario says data is encrypted with an AWS managed key and must cross accounts, the answer is to switch to a customer managed key first.
Encryption in transit and before transit
Encryption in transit on AWS means TLS. Every AWS service API endpoint supports HTTPS, so the work is not enabling TLS — it is refusing everything that is not TLS. For S3, attach a bucket policy that denies all actions when the aws:SecureTransport condition key is false; that single statement guarantees no object can be read or written over plain HTTP. For Amazon Redshift, set the require_ssl parameter to true in the cluster parameter group so JDBC and ODBC clients must connect over TLS. For Amazon RDS and Aurora, require SSL per engine (for example, PostgreSQL's rds.force_ssl) and validate server certificates from the AWS certificate bundle.
Distributed processing frameworks need in-transit protection between their own nodes too. Amazon EMR handles this through a security configuration that enables in-transit encryption with TLS certificates you provide, covering traffic between cluster nodes for frameworks like Spark and Tez. Amazon MSK encrypts traffic between brokers and can require TLS between clients and brokers. AWS Glue connections to JDBC sources can require SSL as part of the connection definition.
Encrypting before transit is the stricter posture: the client encrypts data before it ever leaves the producing system, so even the transport layer only ever carries ciphertext. The AWS Encryption SDK and the S3 client-side encryption feature implement this pattern with KMS-backed data keys, and DynamoDB has client-side encryption support through the AWS Database Encryption SDK. Choose client-side encryption in scenarios where a regulator or contract says AWS itself must never handle plaintext — server-side encryption, however strong, does not satisfy that requirement because the service briefly processes unencrypted data.
Data masking and anonymization: filters, dynamic masking, and tokenization
Masking and anonymization protect data that must remain queryable. Encryption is all-or-nothing per principal; masking lets the same table serve analysts who may see everything and analysts who must never see raw PII, per compliance laws like GDPR and HIPAA or company policy.
AWS Lake Formation data filters apply column-level, row-level, and cell-level security to data lake tables queried through Athena, Redshift Spectrum, and Amazon EMR. A filter can exclude sensitive columns entirely for a given principal (column-level), restrict which rows a team sees (row-level, for example only their own region's customers), or combine both (cell-level). Because Lake Formation enforces the filter at query time in the service, there is no second, scrubbed copy of the data to keep in sync.
Amazon Redshift dynamic data masking attaches masking policies to columns and applies them at query time based on the user's role: a support analyst sees the last four digits of a card number while a fraud team role sees the full value — same table, no duplicated data. For pipeline-time masking, AWS Glue offers a Detect PII transform (backed by managed PII entity detection) that can identify and then redact or hash sensitive fields as data flows through a job, and AWS Glue DataBrew provides redaction, substitution, and deterministic hashing transformations for data preparation. Amazon Macie is the discovery side of the story: it scans S3 buckets with machine learning and managed data identifiers to find where PII lives, telling you which datasets need masking at all.
Know the vocabulary distinctions for the exam. Masking hides part of a value for display. Tokenization replaces a value with a surrogate token and keeps the real value in a separate secure vault — the mapping is reversible only through that vault, and joins on the token still work, which makes it popular for payment data. Hashing is one-way and deterministic, good for joining datasets on an identifier without revealing it. Anonymization is irreversible removal or generalization of identifiers so individuals cannot be re-identified — once truly anonymized, data typically falls outside laws like GDPR, which is exactly why regulators set a high bar for calling something anonymized rather than merely pseudonymized.
Choosing the right control: an exam decision pattern
Match the requirement phrase in the question to the control. "Prove who used the key and when" or "revoke a partner's access immediately" points to a customer managed KMS key and its key policy. "Minimize cost and management overhead for encryption at rest" points to default SSE-S3 or an AWS owned key. "Share encrypted data with another AWS account" means customer managed key plus a two-sided permission setup. "Reduce KMS request charges on a high-throughput bucket" is S3 Bucket Keys. "AWS must never see plaintext" is client-side encryption before transit.
For masking scenarios: "analysts must query the table but never see the SSN column" is a Lake Formation data filter (or Redshift dynamic data masking if the table lives in Redshift); "find out which of our thousands of buckets contain PII" is Amazon Macie; "replace card numbers with reversible surrogates that preserve joins" is tokenization; "remove identifiers permanently so the dataset is out of GDPR scope" is anonymization. If the scenario emphasizes doing this during ETL rather than at query time, reach for the Glue Detect PII transform or DataBrew.
Finally, watch for stems that mix layers. Encryption at rest does not protect data from an authorized user who can query it — that is masking's job. TLS does not protect stored data — that is at-rest encryption's job. A complete answer in a compliance scenario usually stacks all three: KMS at rest, TLS in transit, and masking or filters at the access layer.
Tip. Expect scenario questions that hinge on the AWS managed vs customer managed key distinction, especially for cross-account access to encrypted S3 data or Redshift snapshots. You will be asked to enforce TLS with aws:SecureTransport bucket policies or require_ssl, and to pick the right protection layer — KMS at rest, TLS in transit, or masking at query time. Masking questions typically contrast Lake Formation data filters, Redshift dynamic data masking, Glue PII transforms, and Macie discovery, so know which tool discovers PII versus which one enforces access to it.
- KMS uses envelope encryption: data keys encrypt the data locally, the KMS key encrypts the data keys, and disabling the KMS key instantly revokes access without re-encrypting anything.
- AWS managed keys (aws/s3, aws/redshift) can never be shared across accounts — any cross-account encrypted-data scenario requires a customer managed key.
- Cross-account access to KMS-encrypted data needs both a key policy statement in the key's account and IAM permissions in the consumer account; either one alone fails.
- Enforce encryption in transit by denying requests where aws:SecureTransport is false (S3) and by setting require_ssl for Redshift; EMR in-transit encryption uses a security configuration with TLS certificates.
- S3 encrypts new objects with SSE-S3 by default; use SSE-KMS for auditable key control, S3 Bucket Keys to cut KMS costs, and client-side encryption when AWS must never see plaintext.
- DynamoDB is always encrypted at rest — the only decision is AWS owned (default), AWS managed, or customer managed key.
- Lake Formation data filters give column-, row-, and cell-level masking at query time; Redshift dynamic data masking does the same inside the warehouse; Macie finds the PII that needs protecting.
- Tokenization is reversible via a vault and preserves joins; hashing is one-way and deterministic; anonymization is irreversible and can take data out of GDPR scope.
Frequently asked questions
What is the difference between an AWS managed key and a customer managed key in KMS?
An AWS managed key (named like aws/s3) is created and rotated by AWS for a specific service in your account: you can see its usage in CloudTrail but cannot edit its key policy, disable it, or use it from another AWS account. A customer managed key is one you create and fully control — you write its key policy, enable or disable rotation, add grants, schedule deletion, and can authorize other accounts to use it. Any requirement involving cross-account sharing, custom key policies, or provable key lifecycle control means a customer managed key.
How do I let another AWS account read my KMS-encrypted S3 objects?
Three permissions must line up: the bucket policy must allow the other account to read the objects, the customer managed key's key policy must allow that account (or its specific roles) to call kms:Decrypt, and the other account must attach IAM policies granting its principals those S3 and KMS actions. If the objects are encrypted with the AWS managed aws/s3 key this cannot work at all — you must re-encrypt with a customer managed key first.
How do I force encryption in transit for Amazon S3 and Amazon Redshift?
For S3, add a bucket policy statement that denies every action when the aws:SecureTransport condition key is false, which blocks all non-HTTPS requests. For Redshift, set require_ssl to true in the cluster parameter group so clients can only connect over TLS. Both are exam staples because neither service blocks unencrypted connections for you by policy default.
When should I use masking instead of encryption?
Use encryption to protect data from anyone who lacks the key — it is all-or-nothing per principal. Use masking when authorized users must query a dataset but certain values (card numbers, SSNs, health fields) must be hidden, partially shown, or transformed for some of those users. Lake Formation data filters and Redshift dynamic data masking apply these rules at query time from a single copy of the data, which avoids maintaining a separate scrubbed dataset.
What is the difference between tokenization, hashing, and anonymization?
Tokenization swaps a sensitive value for a surrogate token and stores the real value in a secure vault, so the process is reversible for authorized systems and tokens still join across tables. Hashing applies a one-way function — deterministic, so equal inputs match, but irreversible. Anonymization permanently removes or generalizes identifiers so individuals cannot be re-identified even in principle; genuinely anonymized data generally falls outside privacy laws like GDPR, while tokenized or hashed data (pseudonymized) does not.
What are S3 Bucket Keys and when do they help?
S3 Bucket Keys are an SSE-KMS optimization: instead of calling KMS for every object, S3 uses a short-lived bucket-level key derived from your KMS key to encrypt many objects, cutting KMS API request volume and cost substantially. Enable them on buckets with high object counts or heavy write traffic that use SSE-KMS. The trade-off is that CloudTrail shows fewer per-object KMS events, since KMS is called far less often.
Sign up free to mark lessons complete, bookmark topics and track your exam readiness.