Q&A-1Explain authentication and authorization using a request to delete one production resource.
Answer
The 90-second answer
Authentication answers "who is calling"; authorization answers "may this principal do this to this resource, right now". They fail differently and they log differently, so keep them separate when you debug a delete.
Assume an on-call engineer federated through IAM Identity Center into production account 111122223333, running aws s3api delete-object --bucket prod-customer-exports --key 2024/q3/ledger.csv from a laptop on the corporate VPN. The bucket is versioned and carries a bucket policy.
Authentication is mechanical and comes first. The CLI signs the request with SigV4 using temporary credentials from sts:AssumeRole; the session token carries the role ARN, the role session name, and an expiry (Identity Center defaults to 1 hour, configurable up to 12). S3 verifies the signature against the role's current keys and checks the token has not expired. Success yields a principal, arn:aws:iam::111122223333:assumed-role/AWSReservedSSO_ProdOps_.../alice, and nothing more. A valid signature says the caller holds those credentials; it says nothing about the ledger.
Authorization is a separate evaluation over that principal, the action s3:DeleteObject, the resource ARN, and the request context.
Worked trace
- Explicit deny sweep. SCPs on the OU, the permissions boundary on the role, the bucket policy, the VPC endpoint policy, and any session policy are all checked for a Deny. One match anywhere ends it: deny beats every allow.
- Filter check. SCPs and boundaries never grant; they only cap. If the SCP allows
s3:*but the identity policy has nos3:DeleteObject, the answer is still deny. - Allow check. Same account, so an allow from either the identity policy or the bucket policy is enough. Say the identity policy allows
s3:DeleteObjectonarn:aws:s3:::prod-customer-exports/*whenaws:PrincipalTag/teamispaymentsandaws:SourceVpceis the corporate endpoint. Both conditions hold → Allow. - S3's own controls. IAM said yes; the service can still say no. If the object sits under Object Lock retention or a legal hold, the delete returns 403 AccessDenied. And because the bucket is versioned, this call without a version ID writes a delete marker: the bytes are still there. Destroying them needs
s3:DeleteObjectVersionon each version.
Failure modes
- Expired session. A job that outlives the 1-hour token gets
ExpiredToken(HTTP 400), not AccessDenied. CloudTrail records the error code; alerting only on "AccessDenied" misses it. - Over-broad role. A role holding
s3:*on*makes step 3 trivially true. Detect with IAM Access Analyzer unused-permission findings and CloudTrail-driven policy generation; the cost is blast radius if the session token leaks. - Audit gap. CloudTrail management events are on by default; S3 object-level data events are not, and are billed separately (list price around $0.10 per 100,000 events). Without them you can answer "who called the S3 API" but not "who deleted this key".
Trade-offs
Identity policy vs bucket policy: identity policies centralize and travel with the principal; bucket policies let the data owner grant without IAM write access, and are mandatory for cross-account. Cross an account boundary and both must allow.
SCP/boundary vs per-role policy: filters cap an entire OU in one edit, but cannot grant, so they never replace a real allow.
Coarse s3:* vs per-action with conditions: coarse is faster to operate and wider to lose. Per-action with aws:SourceVpce and principal tags costs more upkeep and shrinks what a stolen token can do.
Soft delete vs hard delete: versioning plus delete markers is recoverable and costs storage; DeleteObjectVersion is irreversible and belongs behind a narrower role.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.