AWS Training
Modules Listen Certification

← Data Engineer IV — Role Review

Starts this lesson and continues through 6 more to the end of the course.

Governance and security — Lake Formation, IAM, and KMS

Why this matters

Every pipeline in lessons 1–5 ends with a role reading S3 and a query engine reading it back. Three systems decide whether that succeeds — IAM, Lake Formation, and KMS — and a request has to pass all of them. Most "AccessDenied" tickets on a data platform are not a missing IAM statement. They are a Lake Formation grant never made, a key policy that doesn't name the Glue role, or a PassRole the deployer lacks. This lesson is about knowing which of the three said no.

What the posting is really asking

The responsibility line is "Implement data governance and security best practices using Lake Formation, IAM, and KMS." Read it as three interview questions: who can see which columns (Lake Formation), which role runs the job and who may hand it that role (IAM), who can decrypt the bytes and how often (KMS). The senior answer connects them — a Glue job needs all three, and only one produces a useful error message.

Lake Formation — two permission systems, both must pass

From Overview of Lake Formation permissions (verified 2026-10-30):

"When a principal makes a request to access Data Catalog resources or underlying data, for the request to succeed, it must pass permission checks by both IAM and Lake Formation."

IAM controls the API (glue:CreateTable). Lake Formation controls the catalog object and the data under it, with DBMS-style GRANT/REVOKE. You can hold CREATE_TABLE in Lake Formation and still fail for lack of glue:CreateTable. And: "Lake Formation permissions apply only in the Region in which they were granted."

The IAMAllowedPrincipals default, and why you remove it

A new account is not actually governed by Lake Formation. Per Changing the default settings (verified 2026-10-30), the initial settings are:

Together: "access … [is] controlled solely by IAM policies. Individual Lake Formation permissions are not in effect." IAMAllowedPrincipals is "any IAM users and roles that are allowed access … by your IAM policies". Until you revoke it, every LF grant you make is decorative.

The API fix, copied from the same page — this turns off the defaults for new resources:

{
    "DataLakeSettings": {
        "DataLakeAdmins": [
            {
                "DataLakePrincipalIdentifier": "arn:aws:iam::<AccountId>:user/<Username>"
            }
        ],
        "CreateDatabaseDefaultPermissions": [],
        "CreateTableDefaultPermissions": []
    }
}

Existing resources need the explicit revoke in Upgrading AWS Glue data permissions: "revoke the Super permission from IAMAllowedPrincipals on each table and database". Automation that creates tables will need its own grants afterwards.

⚠️ Hybrid access mode avoids the big-bang: "an incremental path that allows you to set Lake Formation permissions for a specific set of users without interrupting … existing users".

Data lake administrators

From Create a data lake administrator (verified 2026-10-30): admins "are initially the only IAM users or roles that can grant Lake Formation permissions … to any principal (including self)", and "By default, Lake Formation allows you to create upto 30 data lake administrators." ⚠️ I could not verify whether 30 is adjustable — it is stated in prose, not in a Service Quotas table; check the General Reference.

Implicit permissions: admins have Describe on everything and can grant to anyone, but "do not have implicit permissions to drop databases or alter/drop tables created by others" — they must grant themselves first.

Registered locations and the role

Storage-level enforcement is off until you register the S3 location with a role (Storage access management). After that LF vends temporary credentials: it assumes the registered role and hands the engine scoped-down credentials. Users "don't need direct access to Amazon S3."

Role option Use it when Source
Service-linked role AWSServiceRoleForLakeFormationDataAccess Simplest; LF appends each path to its inline policy service-linked-roles
User-defined role (trusts lakeformation.amazonaws.com; s3:Get/Put/DeleteObject + s3:ListBucket) Required for: another account; the AWS managed key aws/s3; "if you plan to access the location using Amazon EMR" registration-role

The registering admin "must have the iam:PassRole permission on the role". And for encrypted locations: "either the role must have permission to encrypt and decrypt data with the AWS KMS key, or the KMS key policy must grant permissions on the key to the role" (register-encrypted). That sentence is where Lake Formation and KMS meet.

⚠️ Registered with the service-linked role and now want EMR? "You must deregister the location and reregister it with a user-defined role."

Named resources, LF-Tags, and data filters

Method Granularity When
Named resource database, table, column (include/exclude list) Small catalogs
LF-TBAC (LF-Tags) tag expressions, inherited db → table → column "Recommended … when there is a large number of Data Catalog objects"
Data filters row, column, cell — attached to a SELECT grant PII, regional partitions

LF-TBAC (verified 2026-10-30): "Tables inherit LF-Tags from databases and columns inherit LF-Tags from tables. Inherited values can be overridden." The worked example replaces 17 named grants with 5 tag assignments and 4 grants. ⚠️ "IAM tags are not the same as LF-Tags."

Data filters: all-columns wildcard + row expression = row-level; column list + all-rows = column-level; both = cell-level. "Filters apply only to read operations … you can grant only the SELECT Lake Formation permission with filters." The CreateDataCellsFilter body, copied from the doc:

{
     "Name": "restrict-pharma",
     "DatabaseName": "sales",
     "TableName": "orders",
     "TableCatalogId": "111122223333",
     "RowFilter": {"FilterExpression": "product_type='pharma'"},
     "ColumnWildcard": {
         "ExcludedColumnNames": ["customer_name"]
     }
}

Cross-account sharing goes through RAM

Cross-account data sharing (verified 2026-10-30): a cross-account grant "uses the AWS Resource Access Manager (AWS RAM) service to share the resource." Same organization — immediate. Different organization — RAM invitation that "the data lake administrator in the grantee account must … accept." LF-TBAC to Organizations/OUs needs "Cross account version settings to Version 3 or above." ⚠️ Athena and Redshift Spectrum "require resource links to be able to include shared resources in queries".

Which engines honour LF permissions

From Service integrations plus the engine guides (verified 2026-10-30):

Engine Honours LF? Caveat
AWS Glue Yes — same Data Catalog; sees only granted objects Crawlers/jobs need grants once Super is revoked
Athena Reads of registered data only "do not apply when writing objects"; query-results locations "cannot be registered"; no LF control of VACUUM/MERGE/UPDATE/OPTIMIZE on OTF tables
Redshift Spectrum Yes — external schema sees only granted tables/columns Only where LF is available
EMR Release 6.7.0+, Spark/Hive/Presto, "with a runtime role" Location registered with a user-defined role
Amazon Quick Enterprise Needs LF SELECT —

IAM — the four things a data engineer actually hits

Evaluation order

From How AWS enforcement code logic evaluates requests (verified 2026-10-30), in sequence: explicit deny anywhere → Deny; then RCPs; SCPs; resource-based; identity-based; permissions boundary; session policy. Two pipeline details:

Service role vs instance profile

Service Role Who assumes it
Glue job one IAM role, Role is required on CreateJob; trusts glue.amazonaws.com the job run
EMR service role EMR_DefaultRole_V2 — provisioning; EC2 instance profile EMR_EC2_DefaultRole — "application processes … use this role when they call other AWS services"; both "required for all clusters" EMR control plane vs the nodes
EMR + LF runtime role on the step the job, per-user

Source: Configure IAM service roles for Amazon EMR (verified 2026-10-30). Spark's S3 read uses the instance profile (or runtime role) — adding s3:GetObject to EMR_DefaultRole_V2 fixes nothing.

The PassRole trap

Granting a user permissions to pass a role (verified 2026-10-30): "The service then checks whether that user has the iam:PassRole permission." For Glue, Role is a required parameter of CreateJob (and UpdateJob); StartJobRun carries no role, so a deployer without PassRole fails at deploy, not run time. ⚠️ "PassRole is not an API call … no CloudTrail logs are generated" — read the CreateJob event. And: "Do not try to control who can pass a role by tagging the role."

The Glue statement, copied from attach-policy-iam-user:

{
  "Action": [
    "iam:PassRole"
  ],
  "Effect": "Allow",
  "Resource": "arn:aws:iam::*:role/AWSGlueServiceRole*",
  "Condition": {
    "StringLike": {
      "iam:PassedToService": [
        "glue.amazonaws.com"
      ]
    }
  }
}

iam:PassedToService is the condition that stops a role meant for Glue being handed to EC2.

aws:SourceArn / aws:SourceAccount

The confused deputy problem (verified 2026-10-30): "We recommend using aws:SourceArn, aws:SourceAccount, aws:SourceOrgID, or aws:SourceOrgPaths in your resource policies wherever an AWS service principal is granted permission." A bucket or key policy trusting glue.amazonaws.com without one is open to any account that knows the bucket name.

KMS — the data-pipeline angle

Key types, key policies, envelope encryption, rotation and S3's SSE options are covered in certification/SAA1-design-secure-architectures/lessons/05-encryption-and-keys.md. Read that first; this is what a pipeline adds.

Every object is a KMS call

Request quotas (verified 2026-10-30): "Each time you upload or download an S3 object that's encrypted with SSE-KMS, Amazon S3 makes a GenerateDataKey (for uploads) or Decrypt (for downloads) request … These requests count toward your quota." A million small Parquet files is a million Decrypt calls.

Quota Default Adjustable?
Cryptographic operations (symmetric), shared across Encrypt/Decrypt/GenerateDataKey/… 10,000 rps; 20,000 in us-east-2, ap-southeast-1/2, ap-northeast-1, eu-central-1, eu-west-2, eu-south-2; 100,000 in us-east-1, us-west-2, eu-west-1 Yes
CreateGrant 50 rps Yes
DescribeKey 2,000 rps Yes
CloudHSM key store 1,800 rps shared No — the only non-adjustable one

"All AWS KMS request quotas are adjustable, except for the AWS CloudHSM key store request quota." ⚠️ Doc contradiction: the same page's "on your behalf" paragraph still says "5,500 (or 10,000 or 50,000 depending upon your AWS Region)". Quote the table, not the prose.

Cross-account: "AWS KMS throttles the account that makes the requests, not the account that owns the KMS key."

S3 Bucket Keys — the fix for the above

Reducing the cost of SSE-KMS with S3 Bucket Keys (verified 2026-10-30): "can reduce AWS KMS request costs by up to 99 percent" via "a short-lived bucket-level key" that mints per-object data keys inside S3. Three traps:

SSE-S3 vs SSE-KMS vs DSSE-KMS

Protecting data with encryption: SSE-S3 is "the base level of encryption for every bucket" since 5 January 2023 — the real choice is whether you need a key policy, and SSE-KMS gives you one. DSSE-KMS applies "two independent layers of AES-256 encryption", keys "must be in the same Region as the bucket", costs more, no Bucket Keys. For a compliance mandate, not by default.

Scoping a key to a service — kms:ViaService and encryption context

Copied from AWS KMS condition keys (verified 2026-10-30):

{
  "Effect": "Allow",
  "Principal": {
    "AWS": "arn:aws:iam::111122223333:role/ExampleRole"
  },
  "Action": [
    "kms:Encrypt",
    "kms:Decrypt",
    "kms:ReEncrypt*",
    "kms:GenerateDataKey*",
    "kms:CreateGrant",
    "kms:ListGrants",
    "kms:DescribeKey"
  ],
  "Resource": "*",
  "Condition": {
    "StringEquals": {
      "kms:ViaService": [
        "ec2.us-west-2.amazonaws.com",
        "rds.us-west-2.amazonaws.com"
      ]
    }
  }
}

Swap in s3.<region>.amazonaws.com and your Glue role, and a stolen credential can't call kms:Decrypt directly. kms:EncryptionContext:context-key restricts by the key/value pair the service attaches (symmetric keys only).

Grants

Grants: "A grant can allow access to a KMS key, but not deny access", one key per grant, eventually consistent ("use a grant token"). Integrated services create grants on your behalf — denying kms:CreateGrant breaks them.

Multi-Region keys and rotation

Multi-Region keys share "the same key material and key ID, so you can encrypt data in one AWS Region and decrypt it in a different AWS Region without re-encrypting" — what makes a replicated lake readable. Rotation: "Key rotation has no effect on the data that the KMS key protects. It does not rotate the data keys." Rotating never re-encrypts your Parquet.

Check yourself

  1. You granted column-limited SELECT in Lake Formation; the analyst still sees every column in Athena. First check?
  2. CreateJob fails with AccessDenied on iam:PassRole. Why not at StartJobRun, and where in CloudTrail?
  3. EMR Spark gets 403 on governed S3 data; the location was registered with the service-linked role. What's wrong?
  4. KMS throttles at 10,000 rps and the job needs more. Two options?
  5. You enabled key rotation for an auditor who wants old data re-encrypted. Did it?
  6. Cross-account LF share accepted in RAM; Athena in the consumer account shows nothing. Why?
Answers
  1. Whether Super is still granted to IAMAllowedPrincipals on that table or database. While it is, LF grants are not in effect.
  2. Role is a parameter of CreateJob/UpdateJob, not StartJobRun. PassRole emits no CloudTrail event — read the CreateJob event.
  3. EMR needs a user-defined registration role: "deregister the location and reregister it". Also confirm the cluster has a runtime role.
  4. S3 Bucket Keys (up to 99% fewer calls, new objects only), or a quota increase — the symmetric quota is adjustable.
  5. No. "Key rotation has no effect on the data that the KMS key protects." Re-encrypting means copying objects.
  6. Athena needs a resource link in the consumer catalog; the grant alone is invisible to the query editor.

Teaching this section

← PreviousProvisioning with TerraformFinished →Cheat sheet, lab & quiz