devHọc Dev

Week 2 - Day 3: Security and Governance (KMS, Advanced Lake Formation, Macie, Data Privacy, Audit)

Week 2 – Day 3

This lesson combines 5 topics: Encryption with KMS — at-rest and in-transit, Advanced Lake Formation — LF-tags and Cross-account, Macie, Secrets Manager and credential protection, Data Privacy and Masking, Audit and Governance roundup.

Learning Objectives

  • Understand KMS: key types, envelope encryption, key policy
  • Memorize the S3 encryption options: SSE-S3, SSE-KMS, DSSE-KMS, SSE-C, client-side
  • Know at-rest/in-transit encryption on the main data services
  • Troubleshoot KMS permission errors in pipelines
  • Understand LF-TBAC (tag-based access control) and why it scales better than named resources
  • Configure row-level and cell-level security with data filters
  • Master cross-account sharing via Lake Formation + AWS RAM
  • Fit Lake Formation into a multi-account data mesh architecture
  • Understand Amazon Macie: discovering sensitive data in S3
  • Master Secrets Manager vs SSM Parameter Store — pick the right one for the question
  • Integrate secrets into pipelines (Glue, Lambda, Redshift, DMS)
  • Know the neighboring security services: GuardDuty, Security Hub (recognition level)
  • Distinguish the techniques: masking, hashing, tokenization, anonymization
  • Know the masking tools at each layer: Glue, Redshift, Lake Formation, Firehose/AppFlow
  • Design a proper PII-handling pipeline (discover → treat → control access)
  • Master regulatory concepts (GDPR-style) at exam level
  • Put the audit pieces together: CloudTrail, Config, Redshift/S3 logs, Lake Formation audit
  • Understand VPC endpoints for data services (private connectivity)
  • Build a governance framework for a data platform
  • Review the whole week of security with a "requirement → service" table

Part 1: Encryption with KMS — at-rest and in-transit

1. AWS KMS basics

  • KMS key (formerly CMK): a 256-bit key that never leaves KMS; used through APIs (Encrypt, Decrypt, GenerateDataKey)
  • Envelope encryption: KMS generates a data key → data is encrypted with the data key (fast, local) → the data key is encrypted with the KMS key and stored alongside the data
  • Key types: AWS managed (aws/s3... — free, no control over the policy) vs customer managed (control over policy/rotation/grants, $1/month — choose it when you need audit/cross-account) vs AWS owned (invisible)
  • The key policy is the root of permissions on a key (combined with IAM policies); grants give services temporary use
  • Rotation: customer managed keys support yearly automatic rotation; multi-Region keys for DR
  • Keys are regional — data encrypted cross-region needs a key in the destination region (or a multi-Region key)

2. S3 encryption — a must-memorize table

OptionWho manages the keyCharacteristics / when to use
SSE-S3 (default since 2023)S3 manages it (AES-256)Simple, free, no per-key audit
SSE-KMSKMS key (AWS managed or customer managed)Per-key CloudTrail audit, access control, cross-account — the standard for data lakes
SSE-KMS + Bucket Keysas aboveDrastically reduces KMS calls (cost) for write-heavy buckets
DSSE-KMSKMS, two layers of encryptionSpecial compliance requirements
SSE-CCustomer sends the key with each requestSelf-managed keys, rarely used
Client-sideEncrypt before uploadZero trust toward AWS, you handle everything
  • Enforce: a bucket policy that denies PutObject without the s3:x-amz-server-side-encryption header (or use default encryption + block wrong policies)
  • Bucket Keys: a frequently tested cost point — "high KMS request cost on a write-heavy SSE-KMS bucket" → enable Bucket Keys

3. At-rest and in-transit on the data services

ServiceAt-restIn-transit
S3SSE-S3/KMS (above)TLS; bucket policy aws:SecureTransport: false → Deny
RedshiftKMS when creating the cluster/namespaceTLS (require_ssl)
GlueSecurity configuration: S3/CloudWatch/bookmark encryptionTLS; JDBC SSL
Kinesis/FirehoseServer-side encryption with KMSTLS
MSKKMS on EBSTLS broker-client + in-cluster
DynamoDBAlways encrypted (AWS owned/managed/customer key)TLS
EMRSecurity configuration: EBS/local disk + S3 (EMRFS)TLS between nodes
OpenSearchKMSTLS + node-to-node encryption

4. KMS permission errors in pipelines (troubleshooting)

Error pattern number 1: a service reading/writing SSE-KMS S3 gets AccessDenied even with full S3 permissions:

  • The role also needs: kms:Decrypt (read), kms:GenerateDataKey (write) on the key ARN
  • The key policy must also allow that principal (the key policy is the root — an IAM allow without the key policy opening up still fails for a key in another account)
  • Cross-account: key policy in A allows account B + IAM in B allows it — both sides (like S3 cross-account)
  • Firehose/Glue/Redshift COPY use their own role to call KMS — grant permissions to the role that is actually executing

Part 2: Advanced Lake Formation — LF-tags and Cross-account

1. Quick recap (Week 1 Day 1)

Lake Formation = a database/table/column/row/cell permission layer on top of the Glue Catalog + registered S3 locations; engines (Athena, Redshift Spectrum, Glue, EMR) receive vended credentials according to the granted permissions. Remember to revoke IAMAllowedPrincipals so LF actually enforces.

2. LF-Tags — Tag-Based Access Control (LF-TBAC)

The problem with named resources

Granting each table to each team: 100 tables × 20 teams = thousands of grants, and new tables need new grants — it does not scale.

The LF-tags model

1. Define tags:         domain = {sales, hr, finance}
                        sensitivity = {public, confidential, pii}
2. Attach tags to resources: database/table/column
   (email column → sensitivity=pii; orders table → domain=sales)
3. Grant by tag EXPRESSION:
   GRANT SELECT WHERE domain=sales AND sensitivity IN (public, confidential)
   TO role SalesAnalyst
  • New tables/columns with the right tags are automatically inside/outside the permission — no re-granting
  • Tag inheritance: database → table → column (can be overridden at lower levels)
  • This is the answer for: "hundreds of tables, many teams, scalable permission management"

3. Row-level and cell-level security — Data Filters

A data filter on a table consists of:

  • Row filter: a WHERE expression (e.g. country = 'VN')
  • Column include/exclude: restricts columns
  • Combining both = cell-level security
orderstableVNteamsees:┌────┬─────────┬────────┬───────┐┌────┬─────────┬───────┐│id│country│email│total││id│country│total││1│VN│a@x.vn│100│→│1│VN│100││2│US│b@y.us│200│(USrowsfilteredout,│3│VN│c@z.vn│300│emailcolumnhidden)└────┴─────────┴────────┴───────┘└────┴─────────┴───────┘

Grant SELECT with the data filter to a principal — Athena/Spectrum/EMR/Glue enforce it automatically. "Each country team sees only its own country's rows, PII columns hidden" → data filter.

4. Cross-account sharing

How it works

ACCOUNTA(producer—datalake)ACCOUNTB(consumer)LakeFormationgrantReceivestheshareviaAWSRAM(table/databaseorLF-tagexpression)──►acceptresourcesharetoaccountB/OU/organization│▼CreateaRESOURCELINKincatalogB(pointertothesharedtable)│▼InternalgrantinBtoanalysts→Athena/RedshiftSpectrumquery
  • Shares metadata + data permissions, no data copy; S3 stays in account A
  • AWS RAM is the mechanism that carries the share (automatic when granting to an external account)
  • Resource link: a "shortcut" table in B's catalog pointing to the shared table — needed so query engines see it in a local database
  • Supports both named-resource and LF-tag based cross-account (grant by tag expression to an account/OU — scales for data mesh)
  • Version settings: cross-account version 3+ (latest) removes some old required steps — just remember "use the new version"

Compared with other sharing methods

MethodDataFits
LF cross-accountNo copy, fine-grained permissionsMulti-account S3/Glue data lake
Redshift data sharingNo copy, liveBetween Redshift warehouses
Cross-account bucket policyCoarse object-levelSimple files, no table semantics needed
Copy/replicateCopyWhen you need an independent copy (latency, sovereignty)

5. Data mesh with Lake Formation (recognition level)

  • Each domain team has its own account (producer), catalog + governance centralized in a central account; consumers subscribe
  • DataZone/SageMaker Catalog sits on top of Lake Formation as the business layer (publish/subscribe/approval — Week 2 Day 2)
  • Exam: when you see "central governance, multiple producer/consumer accounts, fine-grained" → Lake Formation (+ RAM, resource links, LF-tags)

Part 3: Macie, Secrets Manager and credential protection

1. Amazon Macie

Concept

A service that uses ML + pattern matching to discover sensitive data (PII, financial, credentials) in S3 and assess bucket security posture.

Macie├──Automaticbucketassessment:publicaccess?,encrypted?,shared?├──Sensitivedatadiscoveryjobs(one-time/scheduled)│└──scansS3objects→findings:PII(name,email,SSN,card),│credentials(accesskeysinfiles!),financial...├──Manageddataidentifiers(builtin)+customdataidentifiers(regex)├──Automateddiscovery(continuoussamplingacrosstheaccount)└──Findings→EventBridge→SNS/Lambda(automatedresponse)→SecurityHub

Exam points

  • "Discover PII in S3 data lake" / "scan S3 for sensitive data" → Macie (almost one-to-one)
  • Macie only scans S3 — it does not scan RDS/DynamoDB/Redshift (Redshift/Glue have their own PII features — tomorrow's lesson)
  • Custom data identifier: regex for internal formats (employee IDs, contract numbers)
  • Automation: a "public bucket" finding → EventBridge → Lambda blocks it (remediation)

2. Secrets Manager vs SSM Parameter Store

Secrets ManagerSSM Parameter Store
PurposeCredentials/secretsConfig + lightweight secrets (SecureString)
Automatic rotationYes (managed for RDS/Redshift/DocumentDB; Lambda for anything else)No (build it yourself)
Cross-accountYes (resource policy)Limited (advanced)
Price~$0.40/secret/month + APIStandard is free
Data service integrationGlue connections, DMS endpoints, Redshift COPY... nativeRead via API

Selection rule: need automatic rotation or native database credential integration → Secrets Manager; ordinary/less sensitive config and you want it free → Parameter Store.

Integration in pipelines

  • Glue connection: select a secret instead of entering user/password
  • DMS endpoint: a secret for the source/target database
  • Lambda: read the secret at runtime (cache it with the extension/Powertools — do not call the API on every invocation)
  • Redshift: query editor/Data API authenticate with a secret
  • Exam anti-pattern: credentials in code / plaintext env vars / job parameters / config files on S3 — always wrong

3. Neighboring security pieces (recognition)

ServiceOne sentence
GuardDutyThreat detection from logs (CloudTrail, VPC Flow, DNS...) — detects anomalous behavior, including S3 protection (unusual data reads)
Security HubAggregates findings (Macie, GuardDuty, Config...) + standards scoring (CIS, FSBP)
AWS ConfigRecords resource configuration + rules ("buckets must be encrypted") + auto remediation
IAM Access AnalyzerDetects resources shared outside (buckets, keys, roles)

Quick role split: sensitive data content → Macie; threat behavior → GuardDuty; configuration drift → Config; aggregation → Security Hub.

Part 4: Data Privacy and Masking

1. PII protection techniques

TechniqueHowReversible?Use when
Redaction/MaskingReplace with ****/a fixed valueNoDisplay, logs, analytics that do not need the real value
HashingSHA-256 (+salt)No (but you can join on the hash)Need joins/distinct counts without exposing the value
TokenizationReplace with a token, the mapping table is kept separatelyYes (via a vault)Need controlled recovery of the original value (payments)
Encryption (field-level)Encrypt individual fields with KMSYes (with the key)Strong protection, decrypt by permission
Generalization/AnonymizationCoarsen (age → age group)NoSharing research datasets

A frequently tested distinction: masking/hash = one-way; tokenization/encryption = recoverable under control.

2. Tools at each layer on AWS

At ingest / transform

  • Glue "Detect PII" transform: scans a DynamicFrame, detects PII types (email, SSN...), and acts: redact, hash, or label — masking right inside ETL before it reaches curated
  • Firehose + Lambda transform: mask fields in streaming records
  • AppFlow masking: mask fields directly in a flow from SaaS
  • DataBrew: REDACT/HASH transformations for analysts

At storage / query time

  • Lake Formation: does not mask values, but hides columns/rows/cells per principal (data filters — yesterday). "Different users see different columns" → LF
  • Redshift Dynamic Data Masking (DDM): masking policies by role at query time — same table, an admin sees the full card number, an analyst sees XXXX-XXXX-XXXX-1234; stored data is unchanged
  • Athena: views that hide columns (SELECT without sensitive columns / mask functions in the view) + LF permissions on the view

Quick selection rules

  • The real value must never be stored downstream → mask/hash at ingest/ETL time (Glue Detect PII, Lambda)
  • Real data must be kept, but who sees what depends on permissions → Redshift DDM / Lake Formation filters
  • Must be recoverable → tokenization/field-level encryption (design it yourself with a KMS/DynamoDB vault)

3. Standard PII pipeline (reference architecture)

Source──►rawzone(S3,KMS,minimalaccess—pipelineroleonly)│MaciescanstodetectunexpectedPII(alert)▼GlueETL+DetectPII├─hashemail(joinable),redactcardnumbers▼curatedzone(directPIIremoved)│LakeFormation:remainingsensitivecolumns→allowedrolesonly▼Redshiftmart:DDMforconditionallydisplayedfields

Defense layers: discover (Macie) → minimize (mask/hash at ETL) → control (LF/DDM) → audit (CloudTrail — tomorrow).

4. Regulatory concepts (recognition level for the exam)

  • Data residency: data must stay in a specific region/country → choose the region, block replication outside it (SCP/bucket policy with region conditions)
  • Right to be forgotten: delete one individual's data — design the lake so it can delete by key (Iceberg DELETE is an advantage over plain Parquet)
  • Data retention: keep data for exactly the required period — S3 lifecycle/Object Lock; log retention
  • Purpose limitation / least privilege: permissions by need — fine-grained LF

Part 5: Audit and Governance roundup

1. Audit at each layer

LayerToolWhat it records
AWS APICloudTrail (management + data events)Who called which API (including GetObject if enabled)
ConfigurationAWS ConfigConfiguration state + history, compliance rules
Warehouse queriesRedshift audit logging (connection/user/user activity log → S3/CloudWatch)Who ran which SQL
Lake queriesAthena query history + CloudTrail; Lake Formation records permission grants/usage via CloudTrailWho queried which table
Object accessS3 server access logs (cheap, best-effort) / CloudTrail data events (detailed)Who read the object
Compliance aggregationSecurity Hub, AWS Audit Manager (collects evidence by framework)Standard reports

Audit analysis pattern: logs → S3 → Athena (partitioned tables) or CloudTrail Lake — itself a data pipeline.

2. Private connectivity for data services

The requirement "traffic must not go over the Internet" comes up frequently:

ServiceEndpoint
S3, DynamoDBGateway endpoint (free, route table)
Glue, Athena, KMS, Kinesis, Secrets Manager, Redshift Data API...Interface endpoint (PrivateLink, ENI in a subnet, charged)
RedshiftEnhanced VPC routing (COPY/UNLOAD stay inside the VPC) + RA3 in a VPC
On-prem → AWSVPN / Direct Connect
  • Interface endpoint + endpoint policy: restricts the endpoint to calling specific resources only (e.g. only the company's buckets)
  • Bucket policy condition aws:SourceVpce — the bucket only accepts traffic from the specified VPC endpoint

3. Data platform governance framework (summary of Parts 1–5)

IDENTITY   IAM roles (no hard-coded keys), Identity Center for people
PERMISSION Lake Formation (LF-tags, filters) + IAM + key policy
ENCRYPT    KMS at rest on every layer, TLS in transit, Bucket Keys
PII        Macie (discover) → mask/hash in ETL → LF/DDM (control)
SECRETS    Secrets Manager (rotation), Parameter Store (config)
AUDIT      CloudTrail (+selective data events), Config rules,
           Redshift audit logs, Security Hub / Audit Manager
NETWORK    VPC endpoints, SourceVpce policy, private subnets
RETENTION  S3 lifecycle + Object Lock (WORM) when compliance requires it

S3 Object Lock: WORM (write-once-read-many) — governance mode (admins can remove it) vs compliance mode (nobody can remove it during retention, not even root) — "immutable, regulatory" → compliance mode.

4. "Requirement → service" review table (whole week)

Requirement in the questionAnswer
Audit who used a KMS key to decryptSSE-KMS customer managed + CloudTrail
Reduce KMS cost on a write-heavy bucketS3 Bucket Keys
Tag-based permissions scaling to hundreds of tablesLF-TBAC
Rows/columns per teamLF data filters
Share tables cross-account without copyingLF grant + RAM + resource link
Find PII in S3Macie
Mask PII in ETLGlue Detect PII
Mask by role at Redshift query timeDynamic Data Masking
DB credentials with rotationSecrets Manager
S3 traffic not leaving for the InternetGateway VPC endpoint (+SourceVpce policy)
Immutable logs for a regulatorS3 Object Lock compliance mode
Automatically detect/fix configuration driftAWS Config rules + remediation

Review Questions

  1. Data lake requirements: audit every use of the key for decryption, control who uses the key yourself, share cross-account. Which S3 encryption option do you choose?

    Show answer

    SSE-KMS with a customer managed key: CloudTrail records every Decrypt/GenerateDataKey per key; you control the key policy (you can add other accounts); rotation can be enabled. SSE-S3 has no per-key audit and no policy control; an AWS managed key (aws/s3) does not allow editing the key policy, which makes cross-account hard.

  2. An SSE-KMS bucket receives millions of objects per day, and KMS request costs skyrocket. What is the one-line configuration fix?

    Show answer

    Enable S3 Bucket Keys — S3 uses an intermediate bucket-level key, cutting GenerateDataKey/Decrypt calls to KMS by up to ~99% for heavy write/read workloads. The security model does not change; only request cost goes down.

  3. A Glue job has full S3 permissions but gets AccessDenied reading a bucket encrypted with another account's customer managed key. What do you check?

    Show answer

    Three places: (1) the Glue role's IAM policy has kms:Decrypt on the other account's key ARN; (2) the key policy on the other side allows your role/account; (3) the bucket policy allows cross-account object reads. Cross-account = resource policies (key + bucket) AND the identity policy must all allow. Forgetting the key policy is the most common mistake.

  4. Requirement: "every connection to the bucket must use TLS". How do you enforce it?

    Show answer

    A bucket policy that Denies when "aws:SecureTransport": "false":

    {
      "Effect": "Deny",
      "Principal": "*",
      "Action": "s3:*",
      "Resource": ["arn:aws:s3:::bucket", "arn:aws:s3:::bucket/*"],
      "Condition": { "Bool": { "aws:SecureTransport": "false" } }
    }
    

    An explicit Deny blocks every plain HTTP request regardless of other permissions.

  5. How does envelope encryption work, and why does S3 not send the whole object to KMS for encryption?

    Show answer

    KMS only encrypts small payloads (≤4KB) and should not receive large data. Envelope encryption: S3 calls GenerateDataKey → receives a data key (a plaintext copy + a copy encrypted with the KMS key); the object is encrypted locally with the plaintext data key (which is then discarded), and the encrypted data key is stored with the object; on read, S3 calls Decrypt on the encrypted data key and then decrypts the object locally. Fast, scalable, and the root key never leaves KMS.

  6. An organization has 500 tables, 30 teams, and new tables added weekly. How do you manage permissions without granting each table manually?

    Show answer

    LF-TBAC: define LF-tags (domain, sensitivity...), tag tables at creation (automated in the pipeline), and grant each team by tag expression just once. New tables with the right tags get permissions applied automatically — no re-granting. Named-resource grants for 500×30 combinations are unmanageable.

  7. Requirement: regional analysts only see rows with region = 'APAC' and cannot see the salary column. What do you configure?

    Show answer

    A Lake Formation data filter on the table: row filter region = 'APAC' + column exclude salary, then grant SELECT with that filter to the analysts' role. Row + column combined = cell-level security; every LF-integrated engine (Athena, Spectrum, EMR, Glue) enforces it consistently.

  8. Account B needs to query a table from account A's data lake via Athena. What are the main steps?

    Show answer

    (1) A: Lake Formation grant (SELECT) on the table/database — or by LF-tag — to account B (the RAM share is created automatically); (2) B: accept the RAM share; (3) B: create a resource link in the local catalog pointing to the shared database/table; (4) B: grant permissions on the resource link + shared resource to internal users/roles; (5) query with Athena. The data is not copied — it stays in A's S3.

  9. What is the difference between sharing with Lake Formation cross-account and a cross-account bucket policy?

    Show answer

    Bucket policy: permissions at the object/prefix level, B's engines must understand the layout themselves, no column/row level, hard to audit per table. Lake Formation: shares with table semantics and column/row/cell permissions, catalog metadata comes along, centralized revocation, analytics engines use it immediately. A data lake with table structure → LF is the standard; sharing individual raw files → a bucket policy is enough.

  10. You granted LF cross-account, but analysts in B running Athena report they cannot see the table. What do you suspect first?

Show answer

(1) No resource link created in catalog B (shared tables do not appear in a local database on their own); (2) the RAM share was not accepted; (3) the analyst has no internal grant on the resource link (DESCRIBE) and the shared table (SELECT); (4) old/missing cross-account version settings. "Cannot see the table" is usually the resource link; "AccessDenied when querying" is usually a missing internal grant.

  1. Compliance requires identifying every object containing PII in a data lake of hundreds of TB on S3, and alerting on new discoveries. Solution?
Show answer

Amazon Macie: enable automated sensitive data discovery (continuous sampling) or scheduled discovery jobs on the lake buckets; findings flow through EventBridge → SNS (or Security Hub) for alerts/tickets. Managed data identifiers cover common PII; add custom identifiers (regex) for internal codes.

  1. A Glue job connects to on-prem PostgreSQL; the password must rotate every 30 days without editing the job. Design?
Show answer

Store the credential in Secrets Manager, and have the Glue connection reference the secret (no hardcoding); enable rotation with a Lambda rotation function (RDS has managed rotation built in). The job fetches the credential on every run through the connection → rotation requires no job changes. The Glue IAM role needs secretsmanager:GetSecretValue (+ KMS decrypt on the secret's key).

  1. When is Parameter Store enough instead of Secrets Manager?
Show answer

When you store config (endpoints, feature flags, job parameters) or secrets that do not need automatic rotation, and you want it free (standard tier, SecureString can be KMS-encrypted). Need managed rotation, a cross-account resource policy, or native integration (Glue/DMS/RDS) → Secrets Manager. A question mentioning "automatic rotation" is the Secrets Manager signal.

  1. Can Macie scan Redshift or DynamoDB tables? If not, what do you do?
Show answer

No — Macie only scans S3. For other stores: export/unload a sample of the data to S3 and let Macie scan it; or use in-place features — the Glue "Detect PII" transform in ETL, Redshift dynamic data masking after classifying the data yourself. "PII in S3" → Macie; "PII in a Glue pipeline" → the Detect PII transform.

  1. Assign roles: (a) detect AWS access keys committed into a file in S3; (b) detect an EC2 instance calling a coin-mining domain; (c) detect a bucket without encryption enabled.
Show answer

(a) Macie — scans object contents, has a managed identifier for AWS credentials; (b) GuardDuty — threat detection on DNS/VPC Flow logs; (c) an AWS Config rule (s3-bucket-server-side-encryption-enabled) — configuration drift, with auto remediation. All three feed into Security Hub for a single view.

  1. Requirement: analytics must still count unique users and join on user across tables, but nobody sees the real email. Which technique?
Show answer

Hashing (one-way, salted): replace email with SHA-256(salt + email) right in ETL — the values are consistent, so joins/COUNT DISTINCT stay correct, but the email cannot be recovered. Masking with *** breaks joins; tokenization is overkill (no recovery needed) and adds a vault you must protect.

  1. A Redshift table holds card numbers; support agents may only see the last 4 digits, the fraud team sees them in full — on the same table. Which feature?
Show answer

Redshift Dynamic Data Masking: create a masking policy (e.g. show XXXX... + the last 4) attached to the column, assigned by role — the fraud role gets a pass-through policy, the support role is masked. Applied at query time, stored data is unchanged, no need for two tables.

  1. You want to mask PII directly in Glue ETL before writing to curated without writing regex for each type yourself. Which feature?
Show answer

The Glue Detect PII transform (Glue Studio/API): automatically detects common PII types (email, phone, SSN, credit card...) in a DynamicFrame and lets you choose to redact/hash each detected column or whole cell. This is the "managed" alternative to homemade Lambda/regex.

  1. Distinguish the roles of Lake Formation and masking in PII protection — why are both often used together?
Show answer

Masking/hash (ETL) changes the stored data — the real value does not exist downstream, which is absolutely safe but loses the information permanently. Lake Formation keeps the real data and controls who sees which columns/rows — flexible, but the real data is still there (a risk if permissions are misconfigured). In practice: mask what is never needed (full card numbers), and let LF protect the rest that some roles need.

  1. A GDPR-style requirement to "delete all data for user X" is very hard on a plain Parquet data lake. Which design helps?
Show answer

Plain Parquet: deleting one user = read-filter-rewrite every file containing that user — expensive. Solutions: (1) use Iceberg — DELETE FROM table WHERE user_id='X' with ACID, the engine rewrites automatically; (2) or design to hash/tokenize PII from the start — "deleting" = destroying the token/salt mapping (crypto-shredding), so the remaining data is meaningless; (3) partition/bucket by user is only feasible when the cardinality fits. This is why lakehouse formats win for data with privacy requirements.

  1. A regulator requires transaction logs to be kept for 7 years, and nobody (not even admins) can delete/modify them. Configuration?
Show answer

An S3 bucket with Object Lock in compliance mode and 7-year retention (versioning enabled alongside — mandatory): objects cannot be deleted/overwritten during retention by anyone, including root. Governance mode lets special principals remove the lock — it does not satisfy "not even admins". Combine with lifecycle to Glacier Deep Archive to keep it cheap.

  1. A data lake bucket may only be accessed from the company VPC, not over the Internet. What are the two configuration pieces?
Show answer

(1) Create an S3 Gateway VPC endpoint in the VPC (route table) — a private, free path; (2) a bucket policy Deny when aws:SourceVpce differs from the specified endpoint ID (or an aws:SourceVpc condition) — blocking every other path, including the console/Internet. One side creates the path, the other blocks all remaining paths.

  1. You must prove to an auditor every configuration change to buckets/clusters over 12 months and the compliance state at each point in time. Which service?
Show answer

AWS Config — records configuration history (how bucket policies, encryption, cluster settings changed over time) + rules that evaluate compliance continuously; the timeline can be reviewed for any point in time. CloudTrail adds "who made the change". Audit Manager packages evidence by framework if you need standard reports.

  1. Who ran which SQL statement on Redshift last month — where do you get it from?
Show answer

Enable Redshift audit logging: the user activity log (each SQL statement, user, time) + the connection log, exported to S3 (or CloudWatch Logs) — analyze with Athena. Note that the user activity log requires the enable_user_activity_logging parameter. System tables (STL/SVL) only keep data short-term — not enough for "last month".

  1. Putting it together: a pipeline receives PII files from a partner, with requirements (a) the partner pushes via SFTP; (b) PII is masked before analysts see it; (c) analysts in each country only see their own country's data; (d) all access is auditable. Match the services.
Show answer

(a) Transfer Family SFTP → S3 raw (KMS); (b) Glue ETL + Detect PII hash/redact → curated; (c) Lake Formation data filters row-level country=... for each team via Athena; (d) CloudTrail (+ data events on sensitive buckets) + Athena analysis, with Lake Formation permissions recorded in CloudTrail. A chained question exactly in the style of DEA domain 4.

Hands-on Exercises

Part 1: Encryption with KMS — at-rest and in-transit

  • Create a customer managed key, enable rotation, read the default key policy
  • Set default encryption SSE-KMS + Bucket Keys on the curated bucket; upload and view the KMS CloudTrail event
  • Add a Deny non-TLS policy to a lab bucket and test it with curl over http
  • Read S3 Bucket Keys

Part 2: Advanced Lake Formation — LF-tags and Cross-account

  • Create 2 LF-tags (domain, sensitivity), attach them to the lab database/tables, and grant by tag expression to a test role
  • Create a data filter: row country='VN' + exclude one column, query with Athena under that role
  • Draw the cross-account sharing flow (grant → RAM → resource link → query)
  • Read Lake Formation best practices

Part 3: Macie, Secrets Manager and credential protection

  • Enable Macie in the lab account, run a discovery job on a bucket containing CSV files with fake emails/phone numbers
  • Create a secret in Secrets Manager and attach it to a Glue connection
  • Write a custom data identifier regex for the "EMP-XXXXX" format
  • Read Secrets Manager rotation

Part 4: Data Privacy and Masking

  • Add a Detect PII transform to a Glue Studio job with a hash action on the email column
  • Write a Redshift DDM masking policy for the phone column (simulate it in SQL if you have no cluster)
  • Redraw the 4-layer PII pipeline (discover → minimize → control → audit) from memory
  • Read Redshift dynamic data masking

Part 5: Audit and Governance roundup

  • Enable AWS Config with the s3-bucket-server-side-encryption-enabled rule and view the compliance dashboard
  • Add a SourceVpce condition to the lab bucket policy (be careful not to lock yourself out — test on a scratch bucket)
  • Enable Object Lock governance mode on a new bucket and try deleting an object
  • Review the "requirement → service" table to prepare for the quiz

References


Next lesson →