Skip to Content
Cloud Engineering Academy
5. Security for Banking & Finance

Labs 5.1 and 5.2: IAM policy puzzles, permission boundaries and an offline policy linter

Predict allow or deny for ten IAM evaluation puzzles, confirm each with an offline evaluator and the IAM policy simulator, lint a deliberately bad policy, and design a permission boundary that lets a developer create roles without escalating privileges.

intermediate⏱ 2 h 🟢 FreeSCS-C03SAA-C03SOA-C03

Assumes: .NET 10 LTS · xUnit v3 4.0.3 · hl-policy (lab tool, a simplified teaching model of IAM evaluation) · AWS CLI v2 · IAM policy simulator · Region us-east-1. Verified against official sources on 2026-11-18.

Learning objectives

By the end of these labs you can:

  • Predict, for a request, whether IAM returns Allow, explicit deny or implicit deny, using the evaluation order: explicit deny first, then organisation guardrails, resource policy, identity policy, permissions boundary and session policy.
  • Explain why a Service Control Policy (SCP), a Resource Control Policy (RCP) and a permissions boundary grant nothing; each only caps what other policies grant.
  • Tell a same-account request from a cross-account one, and say which sides must allow it.
  • Run hl-policy lint, explain and evaluate on policies offline, and read the trace line by line.
  • Spot the lint patterns that matter in a bank: full wildcards, iam:PassRole on *, kms:Decrypt on every key, missing MFA conditions on destructive actions, and the Bool-versus-BoolIfExists trap.
  • Design a permissions boundary and a delegated "create roles" policy so a developer can create roles for their application without being able to make themselves an administrator.
  • State where the offline evaluator is a simplification, and why the IAM policy simulator in a sandbox account is the authority.

This page covers Lab 5.1 (policy evaluation puzzles) and Lab 5.2 (permissions boundary). The theory is in Policy evaluation logic and Boundaries, SCPs, RCPs and resource policies.

Prerequisites

Why this matters in banking

A change request says "give the reporting team read access to the statements bucket". Someone adds an identity policy in the reporting account and the job still fails, because the bucket policy in the workload account never granted the role. Someone else "fixes" it with a wildcard principal, and now a statements bucket is readable far more widely than intended. Auditors then ask why the bank's guardrail did not stop it. Every one of these mistakes is a failure to predict the result of a policy combination. People who can predict it make smaller, safer changes and debug access problems in minutes rather than days.

The idea in plain language

When a request arrives, IAM gathers every policy that applies and decides using a fixed procedure. It is not a vote. It works like a building's access system with several layers of locks:

  1. Any explicit deny wins. If any policy says Deny and its condition matches, the answer is deny. Nothing can override it.
  2. Guardrails must permit. Organisation policies (RCPs for resources, SCPs for principals) must not block the request. They are filters: an SCP that says "allow everything" grants nothing.
  3. Someone must grant. Within one account, an identity-based policy or a resource-based policy can grant. Across accounts, both sides must allow.
  4. Caps apply. If the principal has a permissions boundary or a session policy, the request must be allowed by those as well. Effective permissions are the intersection.
  5. If nobody granted, the default is implicit deny.

Analogy: a branch vault. The bank's head office (SCP and RCP) says which vaults any branch may ever enter. The vault's own register (resource policy) says who is on its list. Your keycard (identity policy) says which doors you may open. A temporary visitor pass (session policy) and your department's cap (permissions boundary) shrink what the card can do. A written ban from anyone (explicit deny) beats every list.

What the AWS services do here

  • IAM evaluates the policies. The IAM policy simulator (aws iam simulate-custom-policy and the console) evaluates policies you supply without making real calls.
  • AWS Organizations carries SCPs (what principals in your accounts may do) and RCPs (what can be done to resources in your accounts, including by outsiders).
  • IAM Access Analyzer and policy generation (not used here) help right-size policies from CloudTrail activity.
  • The lab's hl-policy tool is not an AWS service. It is a small offline model so you can experiment quickly, repeatedly and safely.

Microsoft / Azure comparison

You know (Microsoft/Azure)AWS in this labWhat's different
Azure RBAC role assignments (allow only)IAM identity-based policiesIAM policies can also deny, and an explicit deny beats any allow
Azure Policy and management group deny assignmentsSCPs and RCPsSCPs and RCPs never grant. They cap what accounts can do or what can be done to their resources
Entra ID Conditional Access (MFA, location)Condition blocks such as aws:MultiFactorAuthPresentThe condition lives in the policy, and the key may be absent from the request context, which changes the result
Azure PIM and permission scopesSession policies and permissions boundariesBoth only shrink permissions. Neither grants anything
Resource locks and ACLs on a storage accountResource-based policies (bucket, key, queue)A resource policy can grant access to a principal that has no identity policy at all, within the same account

Architecture

The tool follows the same shape and prints a numbered trace (steps 1 to 7), so you can see which step produced the answer. That is a simplification. Real IAM has more cases (for example how a same-account resource policy that names a role differs from one that names a user, and service-linked roles), which is why the last word always belongs to the policy simulator and a sandbox account.

Step-by-step implementation

The lab folder is labs/m05-secure-banking-api. Everything for these labs is in policies/ and the tool is src/Harbourline.Security.PolicyLinter (assembly name hl-policy).

Part 1: run the tests (free)

Run the whole solution's tests in Docker

MSYS_NO_PATHCONV=1 docker run --rm --memory 3g \
  -v "$PWD/labs/m05-secure-banking-api:/src" \
  -v cea-nuget-m05:/root/.nuget/packages \
  -w /src mcr.microsoft.com/dotnet/sdk:10.0 \
  sh -c "dotnet test --solution SecureBankingApi.slnx; find . -type d \( -name bin -o -name obj \) -prune -exec rm -rf {} +"

Expected result (verified 2026-11-18 in Docker): total: 72, failed: 0, succeeded: 71, skipped: 1. This solution also holds the code for the other Module 5 labs. The policy tests are in PolicyTests.cs:

TestWhat it proves
Every_puzzle_evaluates_to_its_expected_answer (per file)Each puzzle's expected field matches the evaluator's answer
There_are_ten_puzzlesNobody deleted a puzzle without noticing
Bad_admin_policy_fails_lint_with_the_expected_rulesThe lint rules fire on bad-wildcard-admin.json
Good_policies_have_no_lint_errors (3 files)The good identity, resource and boundary policies lint clean
Evaluate_command_reports_a_matching_answerThe command-line path works end to end
Explicit_deny_beats_an_allow_in_the_same_policy, No_policy_means_implicit_denyThe two basic rules

If you change a policy file or the tool, run these again. The tests protect the puzzles from drifting.

Part 2: the ten puzzles (Lab 5.1, free)

For each puzzle write your prediction first. Only then run it. A wrong guess teaches more than a right one.

Read a scenario, predict, then run

The scenarios are in policies/scenarios/puzzle-01-...json to puzzle-10-...json. Each names the request, the policy files that apply (identity, SCPs, RCPs, resource policy, boundary and session policy) and an expected answer. Open the file but look away from expected, and write down: Allow, ExplicitDeny or ImplicitDeny, and the one policy statement that decides it.

dotnet run --project src/Harbourline.Security.PolicyLinter -- evaluate policies/scenarios/puzzle-04-boundary-caps-identity.json

The command prints a trace and Decision: and exits with 0 if it matches expected (1 if it differs, 2 on a usage or parse error). To run all ten in Docker with the already built tool, use the same docker run as above with sh -c "for p in policies/scenarios/*.json; do dotnet run --project src/Harbourline.Security.PolicyLinter -- evaluate \$p; done".

The ten requests in short

#SituationLayers in play
1The Accounts API role reads an item from its own DynamoDB tableIdentity policy, SCP full access
2A developer with s3:* deletes an object in the audit-log bucketIdentity allow plus identity deny
3A developer invokes a Lambda function in us-west-2Identity allow, SCP with a Region guardrail
4A developer's identity policy allows secretsmanager:*Identity policy and a permissions boundary
5A developer with a read-only session tries s3:PutObjectIdentity, boundary and session policy
6The reporting account's role reads a statement from the workload account's bucketCross-account, bucket policy does not mention the role
7The same role reads a report from the exports bucketCross-account, bucket policy names the role
8A role in a partner's organisation calls kms:Decrypt on a Harbourline keyRCP and key policy
9A role with no identity policy for KMS, but the key policy names itSame-account resource policy grant
10A security admin schedules a key deletion from a script with no MFA informationA BoolIfExists deny

Confirm the tricky ones with the IAM policy simulator (optional)

For a puzzle you got wrong, or that surprised you, ask AWS. The simulator takes policy documents, an action, a resource and context keys:

# Policy 4: does the developer identity policy allow GetSecretValue? (No boundary here, so expect "allowed".)
aws iam simulate-custom-policy \
  --policy-input-list file://policies/developer-identity.json \
  --action-names secretsmanager:GetSecretValue \
  --resource-arns "arn:aws:secretsmanager:us-east-1:111122223333:secret:hl-m05/accounts-api/blind-index-key-AbCdEf" \
  --profile learn-sandbox

# Now add the boundary: the effective answer is the intersection, so it should be implicitDeny.
aws iam simulate-custom-policy \
  --policy-input-list file://policies/developer-identity.json \
  --permissions-boundary-policy-input-list file://policies/permission-boundary-developer.json \
  --action-names secretsmanager:GetSecretValue \
  --resource-arns "arn:aws:secretsmanager:us-east-1:111122223333:secret:hl-m05/accounts-api/blind-index-key-AbCdEf" \
  --profile learn-sandbox

Read EvalDecision in the JSON output (allowed, explicitDeny or implicitDeny). The --policy-input-list and --permissions-boundary-policy-input-list options exist on simulate-custom-policy; confirm option names with aws iam simulate-custom-policy help on your CLI version (⚠ VERIFY). The simulator does not model SCPs and RCPs the way a live organisation does for custom simulations, so for puzzles 3 and 8 trust the lesson and the evaluator's reasoning rather than the simulator (⚠ VERIFY current simulator coverage).

Part 3: the linter and the explainer (free)

Lint the bad policy

dotnet run --project src/Harbourline.Security.PolicyLinter -- lint policies/bad-wildcard-admin.json

Real output from this build (verified 2026-11-18): the report ends FAIL (7 error(s)), with 12 findings in all. The errors are HL001 (full administrator, Action: "*"), HL003 (permissions-management actions on *), HL005 (iam:PassRole on *, twice) and HL007 (kms:Decrypt on every key, twice). The warnings are HL002 (kms:*), HL003 (write actions on *), HL008 (no Version) and HL009 (sensitive actions without an MFA condition, twice).

Read each finding and its Fix: line. Notice that one statement, Action: "*", trips several rules at once, because * includes iam:PassRole, kms:Decrypt and everything else.

List the rules and lint the good policies

dotnet run --project src/Harbourline.Security.PolicyLinter -- rules
dotnet run --project src/Harbourline.Security.PolicyLinter -- lint policies/good-accounts-api-read.json
dotnet run --project src/Harbourline.Security.PolicyLinter -- lint policies/bucket-policy-tls-only.json --kind resource
dotnet run --project src/Harbourline.Security.PolicyLinter -- lint policies/scp-deny-outside-regions.json --kind scp

rules prints HL001 to HL011. The good identity policy and the TLS-only bucket policy report 0 finding(s) and PASS. The SCP reports one Info finding (HL001) for FullAWSAccess, with the note that this is normal for a guardrail, because the restriction is carried by the Deny statement. The --kind option takes identity, resource, trust, boundary, scp, rcp or session, and changes how some rules apply (a wildcard allow is expected in an SCP).

Explain a policy in words

dotnet run --project src/Harbourline.Security.PolicyLinter -- explain policies/permission-boundary-developer.json

The output (verified) is two lines: CapAtApplicationServices allows five actions (s3:*, dynamodb:*, lambda:*, logs:*, sqs:*) on all resources, and NoBoundaryRemoval denies two actions (iam:DeleteRolePermissionsBoundary, iam:DeleteUserPermissionsBoundary) and adds "An explicit deny overrides any allow in any policy." Use explain on the good Accounts API policy too: its KMS statement is described as allowed "only when at least one value of kms:EncryptionContextKeys equals customer_id".

Part 4: permissions boundaries (Lab 5.2, free)

The problem: a platform team wants developers to create their own application roles, without waiting for a ticket, but never to create a role more powerful than they are. The tool for that is a permissions boundary plus a delegated policy that only allows CreateRole when the boundary is attached.

Read the boundary

policies/permission-boundary-developer.json caps anything it is attached to at five application services, and denies removing a boundary. The developer's identity policy (developer-identity.json) is far broader: it allows six services including Secrets Manager. The boundary is why puzzle 4 returns implicit deny: the effective permission for Secrets Manager is the intersection of "allowed by identity" and "allowed by boundary", which is nothing.

Write the delegated role-creation policy

Create policies/role-creator.json in your copy of the lab (your own file, not part of the original folder). It allows creating and modifying application roles only when the new role carries the boundary:

role-creator.json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "CreateRolesOnlyWithTheBoundary",
      "Effect": "Allow",
      "Action": ["iam:CreateRole", "iam:PutRolePolicy", "iam:AttachRolePolicy"],
      "Resource": "arn:aws:iam::111122223333:role/hl-m05-app-*",
      "Condition": {
        "StringEquals": { "iam:PermissionsBoundary": "arn:aws:iam::111122223333:policy/hl-m05-developer-boundary" }
      }
    },
    {
      "Sid": "DenyBoundaryRemoval",
      "Effect": "Deny",
      "Action": ["iam:DeleteRolePermissionsBoundary", "iam:DeleteUserPermissionsBoundary"],
      "Resource": "*"
    }
  ]
}

The role-name prefix hl-m05-app- limits which roles the developer can touch, so they cannot edit the platform team's roles. Whether iam:PermissionsBoundary is honoured as a request condition for PutRolePolicy and AttachRolePolicy exactly as shown should be confirmed in the policy simulator and the IAM documentation (⚠ VERIFY). The standard documented pattern uses it for CreateRole and the permissions-boundary actions.

Test it with four scenarios

Create four scenario files next to your policy (copy the structure of a puzzle file; policy paths are relative to the scenario file). The request is iam:CreateRole on arn:aws:iam::111122223333:role/hl-m05-app-orders by hl-m05-developer. Change only the context and the action:

ScenarioContextPredictedWhy
Aiam:PermissionsBoundary is the boundary policy ARNAllowThe condition matches the only allow
BNo iam:PermissionsBoundary key at allImplicitDenyStringEquals on an absent key is false, so the allow does not apply
Ciam:PermissionsBoundary is some other policy ARNImplicitDenyThe condition does not match
DAction iam:DeleteRolePermissionsBoundaryExplicitDenyThe deny statement matches

Verified in this build: these four scenarios, run with hl-policy evaluate, gave Allow, ImplicitDeny, ImplicitDeny and ExplicitDeny, and the linter reported one warning (HL009: sensitive IAM actions without an MFA condition) and PASS (no errors) for role-creator.json. Adding an MFA condition is Exercise 🟡.

Why the boundary is not enough on its own

A boundary caps what a role can do. It does not stop that role from creating another role without a boundary, unless the identity policy that allows iam:CreateRole insists on one. That is exactly what the Condition above does, and why the deny on removing boundaries exists. Escalation needs both pieces: the cap, and the rule that every role the developer creates carries the cap.

AWS Console instructions

  • IAM policy simulator: open the IAM Policy Simulator (search "IAM Policy Simulator" in the console), choose a role or paste a custom policy, pick the service and action, fill in resource ARN and context keys, and run. Console wording changes over time (⚠ VERIFY).
  • See a boundary: Console → IAM → Roles → your role → Permissions tab → Permissions boundary.
  • See organisation policies (management account only): Console → AWS Organizations → Policies → Service control policies and Resource control policies.

AWS CLI

# Look up the boundary attached to a role (a role created with one shows PermissionsBoundary).
aws iam get-role --role-name hl-m05-app-orders --query "Role.PermissionsBoundary" --profile learn-sandbox

# Create a role WITH the boundary (what the delegated policy permits). Replace the account id.
aws iam create-role --role-name hl-m05-app-orders \
  --assume-role-policy-document file://trust-lambda.json \
  --permissions-boundary arn:aws:iam::<account-id>:policy/hl-m05-developer-boundary \
  --tags Key=Project,Value=cea-lab Key=Lab,Value=m05-policies Key=Environment,Value=learn Key=Owner,Value=you \
  --profile learn-sandbox

You do not need to create AWS resources for the labs above. The two commands above are optional, to see the real behaviour in a sandbox account. If you run them, delete the role and the policy afterwards (see Cost and cleanup).

Infrastructure as Code

Boundaries and delegated policies are small enough to write directly. The Terraform below creates the boundary policy from the lab file, and a role that carries it.

resource "aws_iam_policy" "developer_boundary" {
  name   = "hl-m05-developer-boundary"
  policy = file("${path.module}/../../policies/permission-boundary-developer.json")
}

resource "aws_iam_role" "app" {
  name                 = "hl-m05-app-orders"
  permissions_boundary = aws_iam_policy.developer_boundary.arn
  assume_role_policy = jsonencode({
    Version = "2012-10-17"
    Statement = [{
      Effect    = "Allow"
      Principal = { Service = "lambda.amazonaws.com" }
      Action    = "sts:AssumeRole"
    }]
  })
}

These snippets are illustrative and were not applied or synthesised in this build (⚠ VERIFY against your Terraform AWS provider and CDK versions; for CDK in C# also remember Amazon.CDK.Tags.Of(this) inside a Stack, and that cdk-nag 3.x uses Validations.Of(...).Acknowledge(...) with exact finding IDs, not the removed suppression API).

Complete code

The evaluator is in src/Harbourline.Security.PolicyLinter/PolicyEvaluator.cs, condition handling in ConditionEvaluator.cs, lint rules in PolicyLinter.cs, the scenario loader in Scenario.cs and the command line in Program.cs. The scenario file format is the one worth knowing, because you will write your own:

policies/scenarios/puzzle-04-boundary-caps-identity.json
{
  "description": "Puzzle 4: the developer's identity policy allows secretsmanager:*, but the permissions boundary does not list Secrets Manager.",
  "request": {
    "principalArn": "arn:aws:sts::111122223333:assumed-role/hl-m05-developer/alex",
    "principalRoleArn": "arn:aws:iam::111122223333:role/hl-m05-developer",
    "action": "secretsmanager:GetSecretValue",
    "resource": "arn:aws:secretsmanager:us-east-1:111122223333:secret:hl-m05/accounts-api/blind-index-key-AbCdEf",
    "context": { "aws:RequestedRegion": "us-east-1" }
  },
  "identityPolicies": ["../developer-identity.json"],
  "scps": ["../scp-full-access.json"],
  "permissionBoundary": "../permission-boundary-developer.json",
  "expected": "ImplicitDeny"
}

And the trickiest policy in the set, the MFA guard from puzzle 10:

policies/admin-with-mfa-guard.json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "SecurityAdminTasks",
      "Effect": "Allow",
      "Action": ["kms:ScheduleKeyDeletion", "kms:DisableKey", "kms:DescribeKey"],
      "Resource": "arn:aws:kms:us-east-1:111122223333:key/*"
    },
    {
      "Sid": "DenyDestructiveKeyActionsWithoutMfa",
      "Effect": "Deny",
      "Action": ["kms:ScheduleKeyDeletion", "kms:DisableKey"],
      "Resource": "*",
      "Condition": { "BoolIfExists": { "aws:MultiFactorAuthPresent": "false" } }
    }
  ]
}

Code explained line by line

  1. "principalArn" is the session ARN (an assumed-role session); "principalRoleArn" is the role itself. Resource policies that name a role match the role ARN, not the session ARN.
  2. "resourceAccount" (optional) tells the evaluator the resource lives in another account. Without it the request is treated as same-account. In puzzles 6 and 7 the principal is in 444455556666 and the resource in 111122223333, so both the bucket policy and the identity policy must allow.
  3. "context" supplies condition keys. An absent key is not the same as a key with value false. That difference decides puzzle 10 and the lab's lint rule HL010.
  4. "scps" is a list, one entry per level of the organisation hierarchy. Every level must allow, which is why puzzle 3 has two entries: an allow-all and the Region guardrail. The evaluator's trace says "SCP level 2" when the second one denies.
  5. "rcps" works the same for resource guardrails. Puzzle 8's RCP denies when the principal's aws:PrincipalOrgID is not the bank's organisation.
  6. "expected" is optional. When present, the command exits 0 on a match and 1 on a difference, which is what makes the puzzles testable in CI.
  7. In admin-with-mfa-guard.json, BoolIfExists means: "the condition is true when the key is absent or when it is present and equals false". A script using long-term keys sends no MFA information, so the Deny fires. A plain Bool would not match an absent key, and the guard would silently let the script through. The lint rule HL010 warns about exactly that.

Security considerations

⚠ Learning shortcut — not for production

hl-policy evaluate is a teaching model. It does not model every IAM feature (service-linked roles, VPC endpoint policies, all condition operators and edge cases, resource-based policies on every service, policy variables in all positions). Never approve a production policy change because the offline tool said Allow or Deny. Use the IAM policy simulator, IAM Access Analyzer policy validation and custom policy checks, and a sandbox account that mirrors production guardrails.

  • Least privilege is a process. Start narrow, then widen with evidence from CloudTrail and Access Analyzer. The lint rules are a net for the worst patterns, not a proof of least privilege.
  • Never rely on a boundary alone. The Condition on iam:CreateRole and the deny on boundary removal are what make it effective.
  • Guard destructive actions. kms:ScheduleKeyDeletion should need MFA (via an Identity Center permission set or a condition) and should usually be limited to a security role.
  • Region guardrails use NotAction carefully: global services (iam:*, sts:*, organizations:*, route53:*, cloudfront:*, support:*, budgets:*) have no Region and must be excluded or the SCP would break them.
  • Fictional data only. Account IDs 111122223333, 444455556666 and 777788889999 are made up. Do not paste real policies from your employer into any tool or page.
  • This lab does not make anything compliant. It trains a skill.

Banking use case

A payments platform team lets product teams create their own Lambda execution roles. The delegated policy only allows iam:CreateRole for names starting with the team's prefix and only when the standard boundary is attached; the boundary caps those roles at DynamoDB, SQS, Lambda and CloudWatch Logs; an SCP denies any action outside two approved Regions; and an RCP prevents principals from outside the bank's organisation from reading any bucket or key, even if a team misconfigures a resource policy. When a team asks "why can't my role read this secret?", an engineer predicts the answer from the policies in two minutes and confirms it in the simulator.

Common mistakes

  • Thinking an SCP grants permissions. It does not. A full-access SCP changes nothing on its own (puzzle 1's Step 3 says "grants nothing by itself").
  • Forgetting the other side of a cross-account grant (puzzle 6).
  • Using Bool where BoolIfExists is needed for "deny unless MFA" (puzzle 10).
  • Assuming a resource policy needs an identity policy too. Within one account, a resource policy that names a role can grant on its own (puzzle 9). Across accounts, it cannot.
  • Putting a boundary on a role and forgetting that the identity policy still has to grant. The boundary only caps.
  • Writing Resource: "*" on iam:PassRole. This is the classic privilege-escalation path (HL005).
  • Trusting your prediction without a trace. Read the numbered steps. If your reasoning skipped a step, find which.

Troubleshooting

SymptomLikely causeFix
Output differs from your predictionUsually a missing-key condition rule (IfExists, negated operators), or a cross-account side you forgotRead the trace step by step; confirm with the IAM policy simulator
error: ... and exit code 2The JSON is invalid, a relative policy path is wrong, or --kind is unknownPolicy paths are relative to the scenario file; kinds are identity, resource, trust, boundary, scp, rcp, session
DIFFERS from expected answerYour edited policy changed the result, or your expected is wrongDecide which is right, then fix the policy or the expectation and run the tests
Simulator says implicitDeny for something you expect to be allowedA required context key is not supplied (for example aws:SecureTransport)Add the key in the simulator's context section
dotnet run is slow in DockerThe first build downloads packagesBuild once with dotnet build -c Release and reuse the container, or use the local SDK
PolicyTests fail after you edited a puzzleThe test enforces ten puzzles with matching expectedRestore the file, or update expected and the lesson that quotes it

Cost and cleanup

Cost: free. The offline tool uses no AWS. The simulator has no charge. If you created the optional role and boundary policy in the sandbox account:

aws iam delete-role --role-name hl-m05-app-orders --profile learn-sandbox
aws iam delete-policy --policy-arn arn:aws:iam::<account-id>:policy/hl-m05-developer-boundary --profile learn-sandbox
# Remove local build output
find labs/m05-secure-banking-api -type d \( -name bin -o -name obj -o -name TestResults \) -prune -exec rm -rf {} +

You may need to detach or delete the role's policies before delete-role succeeds.

Exercises

  • 🟢 Guided: predict all ten puzzles on paper, run them, and record each mismatch with the step that decided it. Then run the linter on bad-wildcard-admin.json and fix the policy until lint passes with no errors.
  • 🟡 Challenge: extend role-creator.json so that iam:CreateRole also requires MFA (Bool on aws:MultiFactorAuthPresent is true) and so that iam:PassRole is allowed only for the application roles and only to lambda.amazonaws.com (iam:PassedToService). Write scenarios for MFA present, MFA absent and the wrong service, and predict each before running.
  • 🔴 Live problem: a ticket reads: "The reporting job in account 4444… gets AccessDenied reading a CSV from the exports bucket since Tuesday. It worked last month. Nobody changed the role." The bucket is in account 1111…. Using only the policy files the team gives you and the evaluator, list every policy layer that could have changed (bucket policy, role policy, SCP, RCP, key policy if the object uses SSE-KMS), say how you would tell which one did, and write the first three CloudTrail or simulator checks you would run.

Assignment

Add two new puzzles to the lab (puzzles 11 and 12) that each teach a different rule. One must involve a session policy that makes a request allowed only because the session policy and boundary overlap; the other must use an RCP or SCP with a condition. Provide the scenario JSON, the policy files, a one-paragraph explanation of the intended lesson, and make the test suite count them (update the count test). Add a short README section "How to add a puzzle". Keep it in your portfolio repository.

Solutions

Knowledge check

Interview questions

  • "Walk me through how IAM decides a request." Gather the policies; any explicit deny wins; organisation guardrails (RCP, SCP) must allow; a resource or identity policy must grant (both, across accounts); a boundary and session policy cap the result; otherwise implicit deny.
  • "What is the difference between an SCP and a permissions boundary?" An SCP applies to every principal in an account or OU, set by the organisation. A boundary applies to one user or role, set in IAM. Neither grants anything.
  • "How do you let developers create roles safely?" A delegated policy that requires a permissions boundary on every role they create, a name-prefix limit, a deny on boundary removal, and a boundary that caps them at the services they need.
  • "How would you check a change before production?" Policy validation and custom policy checks in IAM Access Analyzer, the simulator, a sandbox account that mirrors guardrails, and CloudTrail review after.

Certification practice

Completion checklist

  • I ran the tests and saw total: 72, succeeded: 71, skipped: 1
  • I predicted all ten puzzles before running them and recorded my misses
  • I linted the bad policy and understood each finding
  • I wrote and tested the delegated role-creation policy with four scenarios
  • I know where the offline evaluator is a simplification
  • I deleted bin/ and obj/ and removed any optional sandbox role and policy

Key takeaways

  • Explicit deny always wins; guardrails (SCP, RCP) only cap; boundaries and session policies only cap; someone must grant.
  • Cross-account needs two allows. Same-account can be one.
  • An absent condition key is not a false key. Use ...IfExists deliberately.
  • A boundary helps only when the policy that lets people create roles insists on it.
  • Offline tools build intuition; the simulator and a sandbox account are the authority.

Further reading

Independent learning resource — not affiliated with, endorsed or sponsored by Amazon Web Services. AWS and related marks are trademarks of Amazon.com, Inc. or its affiliates. All banking data in examples is fictional. Sample architectures are for learning and are not automatically compliant with GDPR, PCI DSS or any banking regulation.

On this page