Learning Objectives
- Apply the golden AWS policy evaluation rule: Explicit Deny > Explicit Allow > Implicit Deny.
- Explain why EC2, Lambda, and ECS tasks should always assume short-lived IAM Roles instead of storing `.env` Access Keys.
Prerequisites
- Basic AWS account familiarity and JSON syntax
How AWS Evaluates Every API Call
Before any S3, EC2, or DynamoDB API action executes inside AWS, IAM checks every attached Identity Policy, Resource Policy, Permission Boundary, and Organization SCP using strict order: start at Implicit Deny → any Explicit Deny blocks immediately → require at least one Explicit Allow.
Put IAM security into CI/CD pipelines via GitHub Actions AWS OIDC Guide or explore our AWS SAA-C03 Career Program.
Practical Programming Examples
Scoped Least-Privilege S3 Read + Enforce TLS Condition IAM Policy
Allow reading objects solely inside one S3 prefix while explicitly denying insecure non-HTTPS transport.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowReadScopedPrefix",
"Effect": "Allow",
"Action": ["s3:GetObject"],
"Resource": "arn:aws:s3:::ma-artifacts-prod/syllabi/*"
},
{
"Sid": "DenyInsecureTransport",
"Effect": "Deny",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::ma-artifacts-prod",
"arn:aws:s3:::ma-artifacts-prod/*"
],
"Condition": {
"Bool": { "aws:SecureTransport": "false" }
}
}
]
}
HTTPS GetObject under /syllabi/* succeeds; any plain HTTP call triggers Explicit Deny.
- First statement limits allowed S3 action purely to `s3:GetObject` within the `/syllabi/*` key prefix.
- Second statement enforces encryption in transit (`aws:SecureTransport`) via Explicit Deny.
Common Mistakes to Avoid
- Granting `Action: "s3:*"` and `Resource: "*"` temporarily during setup and leaving it in production.
- Using AWS Root User credentials for daily console tasks instead of locking Root with MFA and working via least-privilege IAM Roles.
Production Best Practices
- Scope both `Action` and `Resource` ARNs narrowly and audit unused access with IAM Access Analyzer.
- Prefer IAM Roles / STS temporary tokens over long-lived IAM Access Keys everywhere.
Technical Interview Relevance
Tested heavily in AWS Solutions Architect (SAA-C03) interviews and Cloud Security technical screens.
Practice & Self-Check Questions
If an Identity Policy allows `s3:PutObject` while an S3 Bucket Policy denies the same caller, what happens?
The request is denied because an Explicit Deny anywhere across applicable policies always overrides any Explicit Allow.