Cert Notes/ Commute Study Notes
Roadmap
KOEN
CLF-C02 · FoundationalCloud Practitioner - Foundational
DVA-C02 · AssociateDeveloper - Associate
SAA-C03 · AssociateSolutions Architect - Associate
SOA-C02 · AssociateCloudOps Engineer - Associate
SAP-C02 · ProfessionalSolutions Architect - Professional
DOP-C02 · ProfessionalDevOps Engineer - Professional
SCS-C03 · SpecialtySecurity - Specialty
  • Week 1
    • 1.Shared Responsibility Model and SCS-C03's 6 Domains: The Big Picture for Security Engineers
    • 2.IAM Core: Users, Groups, Roles, Policies, and Policy Evaluation Flow
    • 3.Advanced IAM Policies: Identity vs Resource, Condition Keys, and Least-Privilege Design
    • 4.STS and Temporary Credentials: AssumeRole, Federation, Role Chaining, Confused Deputy Prevention
    • 5.Week 1 Synthesis: Integrating IAM and Credentials Through Scenarios
  • Week 2
    • 1.Master IAM Policy Evaluation Logic: Explicit Deny Beats Everything
    • 2.Permission Boundary and Delegation: The Safe Way to Grant Permissions to Developers
    • 3.AWS Organizations and SCP: Account-Level Guardrail Design
    • 4.Day 4
    • 5.Day 5
  • Week 3
    • 1.Enable VPC Flow Logs (detailed in Day 3)
    • 2.Scenario: Web server (443) receiving Internet connection
    • 3.1. CloudWatch Logs — suits real-time alarms (Metric Filter)
    • 4.Gateway Endpoint (S3) — add route to table, free
    • 5.Day 5
  • Week 4
    • 1.Day 1
    • 2.AWS Shield (Standard/Advanced) and DDoS Protection: Layered Defense, CloudFront/Route 53 Integration
    • 3.AWS Network Firewall and DNS Firewall: Stateful Inspection, Domain Filtering, Centralized Inspection VPC
    • 4.Edge Security Integration: CloudFront (OAC, Signed URLs), ACM Certificates, Perimeter Security Architecture
    • 5.Week 4 Synthesis: Integrated Review of Edge and Perimeter Defense Scenarios
  • Week 5
    • 1.AWS KMS Fundamentals: CMK Types, Key Policy vs IAM, Symmetric/Asymmetric Keys
    • 2.Envelope Encryption and Data Keys: GenerateDataKey, Encryption Context
    • 3.Key Policies, Grants, and Cross-Account Sharing: ViaService Condition and Key Governance
    • 4.Encryption at Rest/in Transit: TLS, Service-Specific Encryption, Key Rotation
    • 5.Week 5 Synthesis: Integrated Review of Encryption and Key Management Scenarios
  • Week 6
    • 1.Secrets Manager: Automatic Rotation (Lambda), Parameter Store Comparison, Cross-Account Secrets
    • 2.S3 Data Protection: SSE-S3/SSE-KMS/DSSE, Bucket Keys, Object Lock, Versioning, Block Public Access
    • 3.S3 Access Control Deep Dive: Bucket Policies, ACLs, Access Points, Encryption Enforcement, Exfiltration Prevention
    • 4.ACM and Macie: Certificate Lifecycle and Integration, Macie Sensitive Data (PII) Detection and Classification
    • 5.Week 6 Integration: Secrets, Storage, and Sensitive Data Scenario Review
  • Week 7
    • 1.CloudTrail: Management/Data Events, Organization Trail, Log File Integrity Validation, CloudTrail Lake
    • 2.AWS Config: Configuration Items and Records, Rules (Managed/Custom Lambda), Conformance Pack, Auto-Remediation
    • 3.VPC Flow Logs and Network Logging: Detecting Breaches/Misconfig via Traffic, Route 53 Resolver Query Logs
    • 4.Log Integrity, Retention, and Centralization: S3 Object Lock, Cross-Account Log Aggregation, KMS Encryption of Logs
    • 5.Week 7 Integration: Audit Trail Scenario Review
  • Week 8
    • 1.CloudWatch: Log Groups, Metric Filters, Alarms, Anomaly Detection, Security Event Notifications
    • 2.Security Hub: Security Standards (CIS/FSBP), Consolidated Score, Finding Aggregation and Normalization (ASFF), Automated Response
    • 3.Log Analysis: Query CloudTrail/VPC Flow with Athena, OpenSearch, CloudWatch Logs Insights
    • 4.EventBridge Security Automation: Finding Routing, Alert Pipelines, Security Data Lake Concept
    • 5.Week 8 Integration: Monitoring, Aggregation, Analysis Scenario Comprehensive Review
  • Week 9
    • 1.Amazon GuardDuty: Threat Detection Principles, Finding Types, Threat Intelligence, Multi-Account Delegated Administrator
    • 2.Amazon Detective: Finding Investigation and Root Cause, Behavior Graph, GuardDuty Integration
    • 3.Amazon Inspector: EC2/ECR/Lambda Vulnerability Scanning, CVE, Automated Assessment
    • 4.Detection Integration: GuardDuty + Security Hub + Detective + Inspector One Picture, Multi-Account Detection Baseline
    • 5.Week 9 Synthesis: Integrated Review of Threat Detection Scenarios
  • Week 10
    • 1.Automated Response Pipeline: EventBridge + SSM Automation + Lambda for Auto-Remediation of Findings
    • 2.Incident Response for Compromised EC2: Isolation, Snapshots, Forensics, Credential Revocation
    • 3.Credential Exposure Response: Access Key Exposure, Root Compromise, IAM Neutralization and Rotation Playbook
    • 4.Incident Response Framework: NIST Phases, Runbooks, Automation vs Human Judgment Boundary
    • 5.Week 10 Synthesis: Integrated Incident Response Scenario Review
  • Week 11
    • 1.AWS Organizations Security Governance: SCP Design, Delegated Administrators, Central Security Account Model
    • 2.Control Tower and Landing Zone: Guardrails (Preventive/Detective), Account Factory, Compliance Baseline
    • 3.Audit Manager and Compliance: Automated Evidence Collection, Frameworks (CIS/PCI), Config Integration
    • 4.Multi-Account Security Operations: Firewall Manager, Central Policy Distribution, Cost/Tag Governance, Security Baseline Automation
    • 5.Week 11 Comprehensive Review: Integrated Governance Scenarios
  • Week 12
    • 1.Integrated Review Domains 1 & 2: Threat Detection and Incident Response ↔ Security Logging and Monitoring
    • 2.Integrated Review Domains 3 & 4: Infrastructure Security ↔ Identity and Access Management
    • 3.Integrated Review Domains 5 & 6: Data Protection ↔ Management and Governance
    • 4.Full Practice Exam Pace: Six-Domain Synthesis Scenario Review
    • 5.D-Day Final: Exam Strategy, Keyword Translation, Trap Summary
MLA-C01 · AssociateMachine Learning Engineer - Associate
AIF-C01 · FoundationalAI Practitioner - Foundational
DEA-C01 · AssociateData Engineer - Associate
MLS-C01 · SpecialtyMachine Learning - Specialty
← SCS-C03/Week 1/Day 3
SCS-C03· AssociateWeek 1 · Day 3~23 min read

Day 3 - Advanced IAM Policies: Identity vs Resource, Condition Keys, and Least-Privilege Design

Yesterday you learned the policy evaluation algorithm. Today we handle the policies themselves that feed into that algorithm. The real differentiator SCS-C03 tests in IAM isn't "can you write policies" but "among multiple controls producing the same outcome, can you pick the most precise and least-privileged one?" If you solve with Resource policy what should be Identity policy, it works but becomes a trap answer. If you split with separate roles what one Condition key could do, it's over-engineered.

Today we dive into three things. First, when Identity and Resource policies split and how to choose. Second, using Condition keys for precise control — IP, MFA, encryption, tag-based. Third, designing least privilege scalably with Permissions Boundary and ABAC.

Identity-based vs Resource-based: Decision Criteria

AspectIdentity-basedResource-based
Attached toUser/Group/RoleResources (S3, KMS, SQS, SNS, Lambda, etc.)
Principal elementNoneRequired
Main use"What can this principal do""Who can access this resource"
cross-accountCan't work alone (needs counterpart resource policy)Can work alone, allowing other accounts
Typical examplesManaged/inline policiesS3 bucket policy, KMS key policy, IAM Role trust policy

Selection is clear:

  • "Grant permission to a principal within the same account" → Identity policy
  • "Allow different account/service access to my resource" → Resource policy (core tool for cross-account)
  • "Enforce rules uniformly on a resource regardless of who accesses" (e.g., force encryption on all PutObject) → Resource policy

💡 Related Theory: KMS key policy is special. Every KMS key's policy is first authority (authoritative) — if the key policy doesn't permit IAM delegation (allowing "Principal": {"AWS": "arn:aws:iam::ACCOUNT:root"}), then IAM policy alone won't work. S3 and SQS work with either identity or resource policy alone, but KMS requires the key policy to open the gate first before IAM policy functions. That's why cross-account KMS use mandates explicitly stating the other account in the key policy.

🔍 Deep Dive: An IAM Role's trust policy is also a resource-based policy. It's a Principal-including policy on the Role resource defining "who can assume this role (sts:AssumeRole)." That's why cross-account AssumeRole requires ① target account's Role trust policy (Principal naming calling account) ② calling side's identity policy with sts:AssumeRole Allow — both (covered in depth Day 4).

Condition Keys: The Core of Precision Control

Condition is a clause that adds "additional constraints" to policies. Security engineers use these most-common keys, organized by type:

Condition KeyMeaningTypical Use
aws:SourceIpRequest source IPAllow only from corporate IP
aws:MultiFactorAuthPresentMFA authentication presenceForce MFA for sensitive actions
aws:SecureTransportHTTPS or notReject plaintext HTTP
aws:RequestedRegionTarget regionBlock work outside certain regions
aws:PrincipalTag / aws:ResourceTagPrincipal·resource tagsABAC (attribute-based access control)
aws:SourceArn / aws:SourceAccountCalling service sourcePrevent Confused Deputy
s3:x-amz-server-side-encryptionUpload encryption headerBlock unencrypted uploads
kms:ViaServiceKMS call via serviceAllow key use only through specific service

Example 1: Force-Block Unencrypted S3 Uploads

{
  "Sid": "DenyUnencryptedUploads",
  "Effect": "Deny",
  "Principal": "*",
  "Action": "s3:PutObject",
  "Resource": "arn:aws:s3:::secure-bucket/*",
  "Condition": {
    "StringNotEquals": {
      "s3:x-amz-server-side-encryption": "aws:kms"
    }
  }
}

This bucket policy denies all uploads without a KMS encryption header. Classic data protection (Domain 5) and governance enforcement.

Example 2: No Sensitive Actions Without MFA

{
  "Sid": "DenySensitiveWithoutMFA",
  "Effect": "Deny",
  "Action": ["iam:*", "kms:ScheduleKeyDeletion", "ec2:TerminateInstances"],
  "Resource": "*",
  "Condition": {
    "BoolIfExists": {"aws:MultiFactorAuthPresent": "false"}
  }
}

⚠️ Trap: The difference between Bool and BoolIfExists is exam standard. Some requests (service-to-service calls, STS sessions) don't have the aws:MultiFactorAuthPresent key at all. Using Bool to check "false" blocks even normal requests missing the key. BoolIfExists means "if key exists, check if false; if missing, pass" — works as intended. Also, aws:SourceIp doesn't apply to traffic via VPC endpoints — use aws:VpcSourceIp or aws:SourceVpc there.

🔍 Deep Dive: aws:SourceArn and aws:SourceAccount are core to preventing Confused Deputy (confused intermediary) attacks. For example, when S3 sends events to SNS, if the SNS topic policy doesn't use aws:SourceArn to specify "only this bucket," another person's bucket could be tricked into triggering your topic. Service principals (Service principal) should almost always pair with aws:SourceArn/aws:SourceAccount conditions (re-emerges Day 4 in STS context).

Permissions Boundary: Safe Limits for Delegation

Permissions Boundary defines "the maximum permission upper limit this principal can have." Identity policy grants permissions; boundary caps that limit. Effective permission = identity-based policy ∩ Permissions Boundary (intersection).

Most powerful use: safely restricting permission delegation. Give a developer "can create IAM roles" but prevent their created roles from becoming admin.

// Attach to developer: allow role creation but force boundary attachment
{
  "Effect": "Allow",
  "Action": "iam:CreateRole",
  "Resource": "*",
  "Condition": {
    "StringEquals": {
      "iam:PermissionsBoundary": "arn:aws:iam::ACCOUNT:policy/DevBoundary"
    }
  }
}

Now the developer can create roles but only with DevBoundary attached. That role's effective permissions can't exceed boundary — structurally blocking privilege escalation.

💡 Related Theory: The evaluation relationship of four policy types in one picture — SCP(org upper limit) ∩ Permissions Boundary(principal upper limit) ∩ Identity policy(grant) → and explicit Deny takes priority anywhere. SCP and Boundary are "cutting" filters, not "granting" steps. Session policy (passed on AssumeRole) works the same intersection filter.

ABAC: Scalable Least Privilege with Tags

RBAC (role-based) creates policy explosion as roles grow. ABAC (Attribute-Based Access Control) uses tags to express permissions, keeping policy count constant.

{
  "Effect": "Allow",
  "Action": ["ec2:StartInstances", "ec2:StopInstances"],
  "Resource": "*",
  "Condition": {
    "StringEquals": {
      "aws:ResourceTag/Project": "${aws:PrincipalTag/Project}"
    }
  }
}

This single policy expresses "allow when principal's Project tag matches resource's Project tag." 100 projects → 1 policy. New team appears? No policy changes, just grant tags.

🎯 Scenario: "Dozens of teams operate EC2 separately; policy additions for each new team is hitting limits." Answer isn't multiplying team roles and policies — it's ABAC migration. Tag principals with team, resources with team, unify with aws:PrincipalTag/team == aws:ResourceTag/team. Identity Center session tags and SAML/OIDC attributes map to PrincipalTag, applying uniformly to federated users.

Tools That "Discover" Least Privilege

Least privilege isn't intuitive; it's derived from real usage data.

# Access Analyzer: Generate policies from actual CloudTrail log usage
aws accessanalyzer start-policy-generation \
  --policy-generation-details '{"principalArn":"arn:aws:iam::111122223333:role/AppRole"}' \
  --cloud-trail-details '{...}'
 
# Find unused permissions by last-accessed timestamp
aws iam get-service-last-accessed-details \
  --job-id <job-id>

IAM Access Analyzer's policy generation creates policies from only actual recorded calls in CloudTrail. Access Advisor (service-last-accessed) shows "permissions never used in last N months" to justify narrowing over-broad access.

📚 Case Study: Many organizations start with policies near *:*, only narrowing after incidents. Best practice is the opposite: "progressive narrowing — add permissions only when denials occur." Use Access Analyzer-generated policies as a starting point and monitor CloudTrail's AccessDenied. "Broad first, then narrow" creates security debt; "narrow first, then expand" doesn't.

Policy Conflict and Priority Synthesis

Checklist to quickly judge multi-policy tangles:

  1. Any explicit Deny anywhere? → Yes, done — Deny.
  2. SCP allows the Action? → No — Deny.
  3. Permissions Boundary allows? → No — Deny.
  4. (cross-account?) Both accounts allow? → Either missing — Deny.
  5. Any explicit Allow? → No — implicit Deny.
  6. All pass → Allow.

💡 Related Theory: In this order, steps 2-4 (SCP, Boundary, cross-account both) are all "filters that cut upper limits," while step 5 (Identity/Resource Allow) is the "permissions granting" step. Clarifying this distinction lets you quickly pin "permissions exist but denied" as hitting one of those filters (2-4) rather than missing Allow.

Summary — Precision Equals Security

Three essentials today. First, Identity policy handles "what principal can do"; Resource policy handles "who accesses this resource" — cross-account and KMS key policies are Resource policy territory. Second, Condition keys provide precise control via IP, MFA, encryption, tags, but watch for BoolIfExists traps and aws:SourceArn Confused Deputy prevention. Third, Permissions Boundary and ABAC make least privilege "scalable," and least privilege emerges from Access Analyzer and Access Advisor data, not intuition.

Tomorrow we shift to STS and temporary credentials. How AssumeRole exactly works, what federation is, role chaining, and how to block Confused Deputy with ExternalId and aws:SourceArn. Today's trust policy and Condition keys are the raw materials.

📝 Practice Questions

Click a choice to reveal the answer and explanation.

Question 1

A Lambda function in Account A must decrypt data encrypted with a KMS key managed in Account B. What must be configured?

Question 2

Which of the following conditions is intended to mean "deny if MFA is absent" but risks blocking legitimate requests that have no MFA key at all, such as service-to-service calls?

Question 3

An organization faces the operational burden of adding an IAM policy every time a team is added. What is the most appropriate way to implement "allow only when the principal's team tag matches the resource's team tag" without an explosion in the number of policies?

Question 4

You want to grant a developer permission to create IAM roles while enforcing that the roles they create cannot exceed the ceiling they were given. Which mechanism is most appropriate?

Question 5

You want to enforce that every object uploaded to an S3 bucket is encrypted with KMS. What is the most direct approach with no gaps?

PreviousIAM Core: Users, Groups, Roles, Policies, and Policy Evaluation FlowWeek 1 · Day 2Next STS and Temporary Credentials: AssumeRole, Federation, Role Chaining, Confused Deputy PreventionWeek 1 · Day 4

On this page

  • Identity-based vs Resource-based: Decision Criteria
  • Condition Keys: The Core of Precision Control
  • Example 1: Force-Block Unencrypted S3 Uploads
  • Example 2: No Sensitive Actions Without MFA
  • Permissions Boundary: Safe Limits for Delegation
  • ABAC: Scalable Least Privilege with Tags
  • Tools That "Discover" Least Privilege
  • Policy Conflict and Priority Synthesis
  • Summary — Precision Equals Security
  • Practice Questions