Identity, Authentication, and Access Management Questions
Designing and operating identity and access control systems. Covers authentication protocols and standards (OAuth, SAML, OIDC, MFA), authorization models (RBAC, ABAC), identity lifecycle and privilege management, IAM architecture and automation, and access control across cloud and on-premises environments. The 'who can do what' control plane, distinct from cryptographic key management.
Design least-privilege IAM roles for a microservice that: (1) writes ETL outputs to S3 buckets, (2) submits EMR/Dataproc jobs, and (3) reads secrets from Secrets Manager. Describe role boundaries, policies, and how you'd enable cross-account access securely.
Sample Answer
Direct answer
As a data engineer, I would not give this microservice a single role holding all three permissions bundled together; I would split it along the boundary AWS itself already draws between submitting a job and running a job. The microservice's own execution role gets exactly three narrow permissions: submit an Elastic MapReduce (EMR) or Dataproc job, read its own specific secret, and (if it writes small outputs directly) write to its own designated Simple Storage Service (S3) prefix. If the heavy transform work actually happens inside the EMR/Dataproc cluster rather than the microservice's own process, the cluster gets its own separate runtime role for the S3 write, because the identity that submits a job and the identity the job runs as are not the same thing, and conflating them is a common source of over-broad grants.
Structured elaboration
Role boundary 1: the microservice's own execution role (control plane). This is the identity the running microservice process itself assumes (for example, an Amazon Elastic Container Service (ECS) task role or an Amazon Elastic Kubernetes Service (EKS) pod's IAM role via IAM Roles for Service Accounts (IRSA)). Its job is submission and coordination, not necessarily the bulk data movement:
elasticmapreduce:RunJobFlowandelasticmapreduce:AddJobFlowSteps(or the Dataproc-equivalentdataproc.jobs.submit) to launch or add work to a cluster, scoped by resource tags or a specific cluster naming pattern so this role cannot submit jobs to clusters outside its own pipeline.secretsmanager:GetSecretValuescoped to exactly one secret Amazon Resource Name (ARN), the credential this specific microservice needs (for example, a database connection string), never a wildcard across the account's secrets.s3:PutObjectscoped to its own output prefix, only if this microservice's own process (not the cluster it submits to) is what writes the smaller-scale ETL output directly.
Role boundary 2: the EMR/Dataproc cluster's own runtime role (data plane). This is the identity the cluster's own nodes assume while actually executing the submitted job, distinct from the identity that submitted it. On EMR this is the EC2 instance profile role attached to the cluster (separate from EMR's own service role, which lets the EMR service itself manage the cluster's underlying AWS resources); on Dataproc it is the cluster's service account. If the bulk ETL transform and the resulting S3 write happen inside the cluster, this is the role that needs s3:PutObject on the output bucket, not the submitting microservice's role. This distinction matters because it is easy, and common in practice, to grant the submitting microservice's role broad S3 write access "to be safe," when the actual write is performed by a different identity entirely; doing so leaves the submitting role with a permission it never uses, which is exactly the kind of unused grant a least-privilege review should catch.
Role boundary 3: cross-account access, if the output bucket or secret lives in a different account. Rather than issuing long-lived cross-account access keys, the target account (say, the account owning the S3 output bucket) defines a role with a trust policy naming only the specific source-account role ARN as the allowed principal, and the calling role (the microservice's execution role, or the cluster's runtime role, whichever actually performs the write) calls sts:AssumeRole to obtain short-lived credentials scoped to that target role's own narrow permission policy. If the two accounts belong to genuinely separate organizations rather than the same company's account structure, the trust policy should also require an external ID in the assumption request, which prevents a specific "confused deputy" attack where a third party tricks an intermediary into assuming a role on the true caller's behalf. Either way, no static, long-lived credential for the target account is ever stored in the source account's configuration; only a role ARN to assume.
Worked example
flowchart LR
MS["Microservice execution role (Account A)"]
EMR["EMR/Dataproc job submission"]
ClusterRole["Cluster runtime role: EC2 instance profile / Dataproc service account"]
SM["Secrets Manager (Account A)"]
XAcct["Cross-account role in Account B"]
S3["S3 output bucket (Account B)"]
MS -- "RunJobFlow / AddJobFlowSteps (submit only)" --> EMR
EMR -- "runs as" --> ClusterRole
ClusterRole -- "sts:AssumeRole" --> XAcct
XAcct -- "s3:PutObject, scoped prefix" --> S3
MS -- "secretsmanager:GetSecretValue, one ARN only" --> SM
Concretely, a nightly pipeline microservice in Account A needs to: (1) submit a nightly EMR job that transforms raw event data and writes the result to an S3 bucket owned by a separate analytics account (Account B), and (2) read the database credential it needs to log its own run metadata.
The microservice's own execution-role policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "SubmitEmrJobsOnly",
"Effect": "Allow",
"Action": ["elasticmapreduce:RunJobFlow", "elasticmapreduce:AddJobFlowSteps"],
"Resource": "arn:aws:elasticmapreduce:us-east-1:111111111111:cluster/nightly-etl-*"
},
{
"Sid": "ReadOwnSecretOnly",
"Effect": "Allow",
"Action": "secretsmanager:GetSecretValue",
"Resource": "arn:aws:secretsmanager:us-east-1:111111111111:secret:nightly-etl/db-credential-??????"
}
]
}
The EMR cluster's own instance-profile role, separate from the microservice above, is what actually holds the cross-account write:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AssumeCrossAccountWriteRole",
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "arn:aws:iam::222222222222:role/analytics-write-role"
}
]
}
And the target role in the analytics account (Account B) that the cluster assumes, with a trust policy naming only the cluster's own role in Account A:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {"AWS": "arn:aws:iam::111111111111:role/nightly-etl-cluster-role"},
"Action": "sts:AssumeRole"
}
]
}
Each policy JSON above was validated for syntactic correctness (parsed with json.loads: two statements/one statement/one statement respectively, no parse errors) rather than hand-checked by eye alone.
Trade-offs and pitfalls
- Bundling all three permissions into one role is the tempting shortcut and the most common mistake. It looks simpler to manage at first, but it means a bug or a compromised credential in the microservice's own process (a control-plane concern) immediately also has the data-plane S3 write permission, even though the actual write never happens in that process if the cluster does the writing.
- Wildcard resource ARNs on the secret or the EMR cluster name defeat the purpose of splitting roles at all. A secret path pattern like
nightly-etl/db-credential-??????(matching Secrets Manager's own random suffix) is meaningfully narrower than a bare wildcard across the whole secrets namespace; the same discipline applies to the cluster-name pattern on the EMR actions. - Cross-account role assumption without an external ID is fine within one organization's own accounts but risky across organizational boundaries. If the target account ever needs to trust a role controlled by a different company (a vendor's pipeline, for instance), omitting the external ID reopens the confused-deputy risk this pattern is designed to close.
- This design assumes the cluster's runtime role and the submitting microservice's role are cleanly separable in the surrounding orchestration. In some real deployments the "microservice" and the "job" are the same running process (no separate cluster spun up at all), in which case the two role boundaries above collapse into one, and the least-privilege discipline has to be applied within a single role's policy instead of across two roles; the underlying principle (submission permissions and data-plane permissions are conceptually distinct, even if implemented in one policy) still applies.
Propose an RBAC model for ML assets (datasets, feature stores, model artifacts, inference endpoints) in a company with data scientists, ML engineers, security engineers, and business users. Define roles, least-privilege permissions, approval workflows for elevated access, and enforcement mechanisms (IAM, attribute-based access, just-in-time elevation).
Sample Answer
Direct answer
Model access by asset type and lifecycle stage, not by job title alone, since a data scientist's appropriate access to raw training data is not the same as their appropriate access to a production inference endpoint. Define a small set of roles per asset type, give each role the minimum permission that asset type actually needs, gate anything beyond that default through an approval workflow, and enforce the result with a layered combination of identity and access management (IAM) at the infrastructure boundary, attribute-based rules for fine-grained filtering, and just-in-time (JIT) elevation for anything destructive or production-facing.
Structured elaboration
Roles. Define roles distinctly per asset type and population rather than one role per job title: data_scientist_read (read-only on approved, non-sensitive datasets and feature-store namespaces), ml_engineer_deploy (read and write to a staging model registry, production promotion gated separately), inference_operator (can scale or restart a serving endpoint but cannot change its model version without approval), security_engineer_auditor (read-only across everything, for audit, no execute or modify rights anywhere), and business_user_consumer (never touches raw datasets or the feature store directly, only consumes inference results through an application layer).
Least-privilege permissions per asset type.
- Datasets: read-only by default for data scientists, scoped to datasets tagged non-sensitive. A dataset tagged as containing personally identifiable information (PII) requires an explicit elevated grant, never default access.
- Feature stores: read access scoped to a project or team namespace, not the entire organization's feature store; write access to publish new features is granted to the pipeline or service account that owns that namespace, not to individual users directly.
- Model artifacts: data scientists and machine learning (ML) engineers get write access to a staging or experimental registry only. Promoting a model version to production requires the approval workflow below, and deleting a production model version should require a separate, higher-bar approval than promoting one, since deletion is rarer and more destructive.
- Inference endpoints: business users read (query) endpoint outputs through an application layer with its own service identity, never with direct personal credentials. ML engineers get deploy and rollback rights on staging endpoints only; a production endpoint's deploy or rollback requires approval, and direct infrastructure access (for example, shell access to the serving host) should be near-zero standing access for everyone, granted only just-in-time when actually needed.
Approval workflows for elevated access. Define concretely what counts as elevated: reading a PII-tagged dataset, promoting a model to production, modifying a production inference endpoint's configuration, or reaching outside the requester's normal project namespace. Route each to a named approver who actually owns that asset (the dataset owner, the model owner), not a generic IT queue, and issue a grant that is time-boxed and expires automatically. The most common failure in real implementations is an approval that results in a permanent permission change: once approved, access should map to a just-in-time elevation, not a new standing role membership, or the approval step becomes a one-time formality rather than an ongoing control.
Enforcement mechanisms. Three layers, each answering a different question:
- IAM answers "can this identity reach the service at all": a coarse gate at the infrastructure boundary, typically a cloud IAM role or policy bound to a service account or federated identity, controlling reachability to the feature-store service, the model registry API, or an inference endpoint's control plane.
- Attribute-based access answers "which specific rows, features, or datasets within a resource this identity can already reach": fine-grained filtering evaluated per request against attributes of the requester (their project, their sensitivity clearance) and the resource (its namespace, its sensitivity tag).
- Just-in-time elevation answers "does this specific action need a fresh, time-boxed grant right now": no standing elevated credential exists for promoting a model, modifying a production endpoint, or reading a PII-tagged dataset; each such action requires a grant issued after approval, logged, and set to expire automatically rather than persisting.
Worked example
A concrete request-and-approval trace for promoting model version v12 to the production recommendation endpoint:
- A data scientist requests promotion through the ML platform's promotion workflow, naming the model version and the target endpoint.
- Because promotion is defined as an elevated action, approval routes to the model's owner, an ML engineering lead, not a generic access-request queue.
- On approval, a just-in-time grant is issued scoped to exactly "deploy model v12 to endpoint reco-prod" for a fixed window, for example 30 minutes.
- The actual production change is executed by the deployment pipeline's own service identity, not the data scientist's personal credential, using that grant.
- The grant expires automatically at the end of the window.
- The promotion event, the approver, and the time window are all logged, feeding the periodic entitlement review.
Contrast this with the design it replaces: without the just-in-time step, every data scientist would need standing write access to the production model registry so they could promote a model when needed, meaning any of them could promote any model at any time with no approval in the loop, exactly the standing-privilege exposure least-privilege design exists to prevent.
Trade-offs and pitfalls
- An approval that grants permanent access instead of a time-boxed one quietly defeats the design. "Elevated access requires approval" is not the same control as "elevated access requires approval once, then persists forever"; the second is a common implementation gap that looks compliant on paper.
- Namespace-scoped feature-store access is necessary but not sufficient if the namespace itself is too broad. A single namespace shared across forty unrelated models still lets any of their owners see every other model's features; the namespace's granularity has to match the actual blast radius you are trying to limit, not just exist as a checkbox.
- IAM alone, without the attribute-based layer, under-protects. If reachability to the feature-store service is the only control, anyone who can reach the service at all can read every project's features once inside; the two layers are complementary, not substitutes for each other.
- Business users querying an inference endpoint with their own personal credentials, instead of through an application layer's service identity, both over-exposes the endpoint and makes audit trails harder to interpret, since the caller of record becomes an individual person rather than a well-scoped service account whose access pattern is easy to reason about.
Compare role-based access control (RBAC) and attribute-based access control (ABAC) for controlling access to a data lake with both internal users and customer tenants. Provide concrete examples of policies you might use for each model, discuss manageability at scale, performance implications, and how you would enforce row-level and column-level permissions.
Sample Answer
Direct answer
For a data lake with both internal users and customer tenants, pure role-based access control (RBAC) is usually insufficient once you need row-level filtering by tenant and column-level filtering by data sensitivity, because a role name cannot cleanly express "only this tenant's rows." Attribute-based access control (ABAC) handles that multi-dimensional filtering naturally, but the pragmatic answer most real systems land on is RBAC for coarse table-and-dataset-level grants, layered with an attribute-driven policy for the fine-grained row and column filtering, not a strict either/or choice.
Structured elaboration
RBAC in this setting. You define roles like internal_analyst (broad read access to non-sensitive tables) and tenant_viewer (customers reading their own data). The gap shows up immediately: a role grant like "tenant_viewer can SELECT on orders" says nothing about which tenant's rows a specific tenant_viewer should see. The naive fix, one role per tenant (tenant_viewer_acme, tenant_viewer_globex, and so on), is the real manageability failure mode: role count grows with every dimension you need to distinguish, not just with the number of user types.
ABAC in this setting. Attributes of the requester (their tenant_id, their department, whether they are cleared for personally identifiable data) are compared against attributes of the data (the row's tenant_id, the column's sensitivity tag) at query time by a policy engine. One policy rule like "allow a row when the row's tenant_id equals the requester's tenant_id, and allow a personally-identifiable-information (PII) column only if the requester is separately marked as PII-cleared" replaces what RBAC would otherwise need dozens or hundreds of distinct roles to express.
Manageability at scale. RBAC's role count grows combinatorially with the number of independent dimensions you must control. If you need to distinguish access along both tenant and sensitivity tier, and you tried to do that purely with roles, the role count is the product of the two dimensions' sizes, shown in the worked example below. ABAC's rule count stays roughly constant as tenants are added, a new tenant is just a new attribute value, not a new role, but it pushes the complexity into writing and testing the shared policy logic correctly: a wrong predicate in one centralized rule can affect every tenant at once, where a misconfigured RBAC role only affects its own members. That is the honest trade-off, not "ABAC is simply better."
Performance implications. An RBAC check (is this identity a member of role X) is a cheap set-membership lookup, usually cacheable per session and evaluated once. An ABAC row-level check pushes a predicate like "row.tenant_id equals user.tenant_id" into every query. A data lake's query engine can execute that efficiently if the tenant_id column is used for partitioning or clustering, so the predicate becomes partition pruning (the engine skips whole partitions instead of reading them), but it performs poorly if the engine has to fetch every row and filter afterward, a real risk for row-level security implementations that apply the filter as a post-fetch step rather than pushing it down into the scan. Column-level checks are cheaper by comparison, since they are evaluated once per column in the query plan rather than once per row.
Enforcing row-level and column-level permissions. Three mechanisms are common in practice: a policy-enforcement layer (for example a project like Apache Ranger, a widely used open-source authorization layer in the Hadoop and data-lake ecosystem) that intercepts and rewrites incoming queries to inject the row filter and column mask based on the requester's attributes; a table format's native row-filter and column-mask features, defined declaratively and enforced by the query engine itself; or, as a simpler fallback, parameterized views that bake the tenant predicate into the view definition so any application querying "the table" is actually always querying a pre-filtered view. All three land on the same idea: the filtering predicate has to be enforced at or before the scan, not trusted to application code above the query layer.
Worked example
Concrete RBAC policy, showing exactly where it falls short:
-- RBAC: coarse role-to-table grants
GRANT SELECT ON lake.sales.orders TO ROLE internal_analyst;
GRANT SELECT ON lake.sales.orders TO ROLE tenant_viewer;
-- Gap: this grant alone lets any tenant_viewer see every tenant's rows.
-- Expressing "only this tenant's rows" is not something a role grant can say.
Concrete ABAC policy for the same table, expressed as a policy rule:
package datalake.authz
default allow = false
allow {
input.action == "select"
input.row.tenant_id == input.user.tenant_id
not blocked_by_sensitivity
}
blocked_by_sensitivity {
input.column.sensitivity == "pii"
not input.user.has_pii_access
}
One rule set like this replaces a combinatorial number of RBAC roles. If a data lake serves 200 tenants and needs 3 distinct sensitivity tiers (public, internal, PII) enforced through role grants alone, the role count needed is the product of the two dimensions:
200 tenants x 3 sensitivity tiers = 600 distinct roles
against a fixed handful of ABAC policy rules (five to ten, in practice, covering the row-tenant match and the column-sensitivity check above plus a few administrative overrides) that do not grow as the 201st tenant is onboarded.
Trade-offs and pitfalls
- ABAC concentrates correctness risk into shared policy logic. A wrong predicate in the centralized rule can silently break access for every tenant at once, where a misconfigured RBAC role only affects its own members. Centralized access-control policies deserve the same review rigor as production code, not less.
- Naive row-level security can perform far worse than it looks in a demo. If the tenant predicate is applied as a filter after the engine has already scanned every row, instead of being pushed down as partition pruning, query cost scales with total lake size rather than with one tenant's slice of it, a performance cliff that only shows up once tenant count or data volume grows.
- Choosing one model exclusively is the common mistake. RBAC alone cannot express fine-grained tenant or sensitivity filtering without role explosion; ABAC alone, used even for coarse "can this role touch this table at all" decisions, adds policy-engine overhead where a simple grant would do. The hybrid split (RBAC for coarse access, attribute rules for fine-grained filtering) keeps both models doing what they are actually good at.
- Auditability is a real cost of pure ABAC. "This person has role X, therefore access Y" is far easier to explain to a compliance reviewer during an access review than "this dynamic rule happened to evaluate to true for this row," which matters when a periodic entitlement review has to be defensible to someone outside the engineering team.
How would you handle secrets and model artifacts in a multi-tenant environment where models require access to private feature stores and third-party APIs? Discuss authentication and authorization (workload identities), fine-grained access control, artifact signing and provenance, encryption at rest/in transit, and auditability requirements.
Sample Answer
Direct answer
Treat each machine learning (ML) job as its own workload identity, not a shared static credential: issue it a short-lived, tenant-scoped identity to authenticate to the feature store and any third-party API, enforce fine-grained access control on top of that identity so it can only reach its own tenant's data, sign and track provenance for every artifact it produces or consumes, encrypt everything at rest and in transit, and log every identity, access, and signing event so the whole chain is auditable afterward.
Structured elaboration
Authentication and authorization via workload identities. Each ML job or service gets its own machine identity rather than a long-lived, embedded API key. In practice this usually means workload identity federation: the platform verifies the job's own runtime identity (for example, that it is genuinely running as the expected pipeline, in the expected environment) and exchanges that for a short-lived, narrowly scoped cloud credential, rather than baking a static secret into the job's configuration. This directly addresses the multi-tenant risk in the question: if a job for tenant A and a job for tenant B shared one static service-account key, a compromise or misconfiguration of either job carries the same blast radius as the other. Per-job, expiring, tenant-scoped credentials bound that blast radius to the one job and the one short window it was valid for.
Fine-grained access control. Once authenticated, the workload's identity carries a tenant claim, and the feature store and any third-party API enforce access decisions keyed on that claim, returning or accepting operations only for the tenant matching the caller's identity. This has to be enforced server-side, at the feature store and the API themselves, not only trusted from the calling job's own code, because a compromised or simply buggy job could otherwise request another tenant's data and receive it without any control actually stopping it.
Artifact signing and provenance. Every model artifact, and ideally every dataset snapshot used to train it, is cryptographically signed at creation time, with a provenance record capturing which dataset version, which code version, and which identity produced it. Before deployment, or before a downstream job consumes an artifact, that signature and provenance chain gets verified. This answers a different question than encryption does: encryption protects confidentiality (can an unauthorized party read the data), signing protects integrity and authenticity (was this artifact actually produced by the approved training pipeline, or did something else write to this location). A multi-tenant environment with third-party API access needs both, not one standing in for the other.
Encryption at rest and in transit. Artifacts and data are encrypted at rest using a key management service, so encryption keys are managed and rotated centrally rather than embedded in application configuration, and all data in motion, job to feature store, job to third-party API, travels over Transport Layer Security (TLS), the standard protocol that encrypts network traffic. In a multi-tenant setting specifically, consider whether tenants warrant cryptographically separate encryption keys, not just separate access-control rules, so a key-management misconfiguration affecting one tenant cannot expose another tenant's data at the storage layer even if the access-control layer were somehow bypassed. This is a defense-in-depth argument, sized to how sensitive the data actually is, not a requirement for every dataset regardless of sensitivity.
Auditability. Log every workload-identity issuance and exchange (which job received which scoped credential, when, for how long), every access-control decision at the feature store or API (allowed or denied, and why), and every artifact signing and verification event, correlated by tenant and by job run. This is what lets an auditor or an incident responder reconstruct, for any given model artifact, exactly which data it touched, which identity produced it, and what consumed it downstream.
Worked example
The request-time flow for authentication, authorization, and fine-grained access control:
sequenceDiagram
participant Job as ML training job (tenant A)
participant Cloud as Cloud IAM (workload identity federation)
participant Vault as Secrets vault
participant FS as Feature store (tenant A partition)
Job->>Cloud: Present platform-issued short-lived identity token
Cloud->>Cloud: Verify token issuer, audience, tenant claim
Cloud-->>Job: Federated short-lived cloud credential (minutes, scoped to tenant A)
Job->>Vault: Request feature-store credential using federated identity
Vault->>Vault: Check policy: does tenant A identity have this scope?
Vault-->>Job: Short-lived, tenant-scoped access token
Job->>FS: Read features using scoped token
FS-->>Job: Tenant A features only
Reading this against the elaboration above: the first three messages are the workload-identity authentication step (the job never holds a long-lived secret, only a short-lived token it exchanges). The vault's policy check and the feature store's response scoped to "tenant A features only" are the fine-grained access control step, enforced server-side by the vault and the feature store, not by the job's own code. This diagram covers the input side of the job, reading training data. On the output side, once training completes, the resulting model artifact is signed and its provenance recorded (dataset version, code version, and the job's own identity from this same flow) before it is written anywhere a downstream job or deployment pipeline could read it, and both the artifact and any cached training data are encrypted at rest with a key management service, with TLS covering every hop shown in the diagram.
Trade-offs and pitfalls
- A shared, long-lived service account across every tenant's jobs is the single most dangerous shortcut here. It is operationally simpler, fewer credentials to manage, but it collapses the actual security boundary between tenants down to "trust every job's code to behave correctly," which fails the moment any one job has a bug or is compromised.
- Enforcing tenant scoping only in the calling job's own code, rather than server-side at the feature store or API, is advisory, not a control. A compromised or misconfigured job can simply skip a check that lives only in its own logic; the enforcement has to sit at the resource being protected.
- Signing artifacts without any consumer actually verifying the signature makes the whole practice decorative. The value of provenance only exists if every deployment pipeline and downstream job checks it before trusting an artifact, not merely if it was applied at creation time.
- A single shared encryption key across all tenants protects against external attackers but not against your own system's bugs crossing a tenant boundary. Per-tenant keys add real operational overhead, more keys to manage and rotate, for a genuine defense-in-depth benefit; that cost should be weighed against how sensitive the specific data actually is, not applied uniformly regardless of sensitivity.
Write an AWS IAM policy in JSON that grants a single principal read access to objects in a specific S3 bucket named my-app-logs without allowing list or delete operations. Explain why the policy enforces least privilege and which actions you intentionally omitted.
Sample Answer
Direct answer
Least privilege in Identity and Access Management (IAM) means granting exactly the actions a principal needs and nothing else, and Amazon Web Services (AWS) IAM enforces this through implicit deny: any action not explicitly allowed by a policy is denied by default, so achieving "read access only, no list or delete" is simply a matter of writing a policy statement for s3:GetObject and stopping there. Below is a minimal identity-based policy (attached to the one principal that needs it) granting exactly that.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowGetObjectOnAppLogsBucket",
"Effect": "Allow",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-app-logs/*"
}
]
}
Structured elaboration
Why this is an identity-based policy, not a bucket policy. The question asks for "an AWS IAM policy" granting access to "a single principal," which is exactly what an identity-based policy is for: it is attached directly to one IAM user or role, so its scope is that one principal by construction. A resource-based bucket policy would instead live on the bucket itself and require an explicit Principal element naming who it applies to, which matters if the principal is in a different AWS account or if the grant needs to be visible from the resource side; neither is needed here since the principal is a single, presumably same-account identity.
Why the Action is s3:GetObject and nothing broader. s3:GetObject is the specific Simple Storage Service (S3) permission for reading an object's content. It intentionally does not authorize:
s3:ListBucket: this is a bucket-level (not object-level) permission that lets a caller enumerate the keys in the bucket. It is easy to assumeGetObjectimplies the ability to browse the bucket, but AWS treats listing and reading as two separate permissions on two separate Amazon Resource Name (ARN) shapes (the bucket ARN forListBucket, versusbucket-name/*for object-level actions), and the question explicitly asks that listing not be allowed.s3:DeleteObject: object deletion is its own distinct action; omitting it means the policy grants no path to destructive operations at all, satisfying "without allowing list or delete" for the delete half explicitly.s3:PutObject,s3:GetBucketAcl, and every other S3 action: none of these are named in the question, and under least privilege the correct default is to grant nothing beyond the one action actually required, not to reason case by case about which additional actions "probably wouldn't hurt."
Why the Resource is arn:aws:s3:::my-app-logs/* and not the bare bucket ARN. Object-level actions like GetObject operate on individual objects, whose ARNs are the bucket ARN plus a key path, hence the trailing /*. The bare bucket ARN (arn:aws:s3:::my-app-logs, no trailing /*) is what bucket-level actions such as ListBucket operate on; including it here would be both unnecessary (this policy doesn't grant ListBucket) and a subtle scope-creep risk if a future edit added a bucket-level action to this statement without noticing the resource line needed to change too.
Worked example
The policy was parsed and exercised against the three actions the question cares about (get, list, delete) using a small policy evaluator that implements AWS's real default: implicit deny for anything a policy doesn't explicitly allow.
import json
# The IAM policy document itself (identity-based: no Principal element,
# meant to be attached to exactly one IAM principal, e.g. an IAM user/role
# named "log-reader").
POLICY_JSON = """
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowGetObjectOnAppLogsBucket",
"Effect": "Allow",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-app-logs/*"
}
]
}
"""
# 1) Validate it is syntactically valid JSON.
policy = json.loads(POLICY_JSON)
print("Parsed OK. Statement count:", len(policy["Statement"]))
def action_allowed(policy_doc, action, resource_arn):
"""Minimal identity-based policy evaluator: exact-match or trailing-'*'
wildcard match on Action and Resource, single-statement Allow, and
implicit deny (AWS's real default) if nothing matches."""
for stmt in policy_doc["Statement"]:
actions = stmt["Action"]
if isinstance(actions, str):
actions = [actions]
resources = stmt["Resource"]
if isinstance(resources, str):
resources = [resources]
def matches(pattern, value):
if pattern == value:
return True
if pattern.endswith("*") and value.startswith(pattern[:-1]):
return True
return False
for a in actions:
if matches(a, action):
for r in resources:
if matches(r, resource_arn):
return stmt["Effect"] == "Allow"
return False # implicit deny: no statement matched
# 2) Exercise the three actions the question asks about.
tests = [
("s3:GetObject", "arn:aws:s3:::my-app-logs/2026/07/28/app.log"),
("s3:ListBucket", "arn:aws:s3:::my-app-logs"),
("s3:DeleteObject", "arn:aws:s3:::my-app-logs/2026/07/28/app.log"),
]
for action, resource in tests:
allowed = action_allowed(policy, action, resource)
print(f"{action:16s} on {resource:55s} -> {'ALLOW' if allowed else 'DENY (implicit)'}")
Output (actually run):
Parsed OK. Statement count: 1
s3:GetObject on arn:aws:s3:::my-app-logs/2026/07/28/app.log -> ALLOW
s3:ListBucket on arn:aws:s3:::my-app-logs -> DENY (implicit)
s3:DeleteObject on arn:aws:s3:::my-app-logs/2026/07/28/app.log -> DENY (implicit)
This is exactly the behavior the question asks for: reading an object succeeds, and listing or deleting fail, both by omission (implicit deny) rather than by an explicit Deny statement, which is the idiomatic least-privilege style: write only what is allowed, and let AWS's default handle everything else.
Complexity and edge cases
This is a declarative policy document evaluated by AWS's own policy engine at request time, not client-side algorithmic code, so there is no meaningful Big-O cost to analyze; the evaluator above is a teaching simplification of that engine's logic, and its own cost is linear in the number of statements and the number of Action/Resource entries per statement; for a real AWS account the actual engine also merges in service control policies, permission boundaries, and any applicable resource policy, none of which this single-statement policy alone can express. Edge cases worth naming explicitly:
- A key with no extension or an unusual character in its path (
my-app-logs/2026/07/28/app.log.gz, or a key containing a literal*) still matchesmy-app-logs/*correctly, since S3 key matching is prefix-based on the ARN string, not a filename-extension check. - A request for an object in a different bucket, even one with a similar name (
my-app-logs-archive), correctly falls to implicit deny, because the resource ARN does not match themy-app-logs/*pattern. - A request using temporary, assumed-role credentials for the correct principal still evaluates identically, since the policy is attached to the principal, not to a particular credential type.
Trade-offs and pitfalls
- The most common mistake is granting
s3:*"to be safe," which is the opposite of least privilege. A wildcard action is easy to write and rarely revisited, and it silently grants delete and list alongside read, exactly the two permissions this question asks to withhold. - Forgetting the trailing
/*on the resource ARN, or including it when it shouldn't be there, is a frequent, subtle bug. Because object-level and bucket-level actions use different ARN shapes, a policy author who copies a bucket-level example and addsGetObjectto it without adjusting the resource can end up with a policy that fails at runtime (anAccessDeniedonGetObjectbecause the resource ARN was the bucket, notbucket/*) rather than one that over-grants, so this particular mistake tends to be caught in testing rather than in a security review, which is a weaker safety net. - This policy alone doesn't prevent the object's own Access Control List (ACL) or the bucket's public-access settings from independently allowing broader access. IAM policy is one of several access-control layers on an S3 object (bucket policy, ACLs, and S3 Block Public Access settings all also apply); a least-privilege IAM policy is necessary but not sufficient if the bucket itself is separately configured to be public.
- A single-action, single-resource policy like this one doesn't scale as a pattern if there will be many similar readers. For one principal it is exactly right; if ten services each need the same narrow read access, the better long-term design is a shared managed policy (or a permission boundary) rather than ten hand-copied inline policies that will drift out of sync the first time the access requirement changes.
Unlock Full Question Bank
Get access to all 12 Identity, Authentication, and Access Management interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.