SkillSprout
Chapter 3 · Lesson 4
Intermediate
8 min read

Policies

Overview

An IAM policy is a JSON document that defines permissions. It lists statements, each of which says whether an Effect (Allow or Deny) applies to certain Actions on certain Resources, optionally under certain Conditions. Policies are attached to identities (users, groups, roles) or to resources (S3 buckets, SQS queues, KMS keys) and are evaluated every time you make a request.

By default everything is denied. A request is allowed only if some policy explicitly allows it and nothing explicitly denies it. This simple rule — default deny, explicit allow, explicit deny overrides — is the core of IAM and appears on the exam in many disguises.

You will meet several kinds of policy: identity-based, resource-based, permissions boundaries, Service Control Policies (SCPs) and session policies. Understanding how they combine is the difference between guessing and knowing the answer.

Key Concepts

  • Policy elements: Version (use 2012-10-17), Statement with Sid, Effect, Principal (resource policies only), Action/NotAction, Resource/NotResource and Condition.
  • Default deny -> an explicit Allow is needed -> an explicit Deny always wins.
  • Identity-based policies attach to users, groups and roles; resource-based policies attach to resources and include a Principal.
  • AWS managed policies are maintained by AWS; customer managed policies are yours and versionable (up to 5 versions); inline policies are embedded in a single identity.
  • Permissions boundary: maximum permissions an identity-based policy can grant a user or role; it never grants by itself.
  • SCPs (AWS Organizations) set the maximum available permissions for accounts; they never grant by themselves and don't affect the management account.
  • Session policies limit a role/federated session further when it is assumed.
  • Size limits: managed policy 6,144 characters; inline policy for a user 2,048, group 5,120, role 10,240 characters.
  • Conditions use keys such as aws:SourceIp, aws:RequestedRegion, aws:MultiFactorAuthPresent, aws:PrincipalOrgID, aws:PrincipalTag and s3:prefix.

Detailed Notes

Anatomy of a policy

json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ReadReportsBucket",
      "Effect": "Allow",
      "Action": ["s3:GetObject", "s3:ListBucket"],
      "Resource": [
        "arn:aws:s3:::acme-reports",
        "arn:aws:s3:::acme-reports/*"
      ],
      "Condition": {
        "IpAddress": { "aws:SourceIp": "203.0.113.0/24" }
      }
    }
  ]
}
ElementMeaning
VersionPolicy language version; always 2012-10-17
SidOptional statement id
EffectAllow or Deny
PrincipalWho — only in resource-based and trust policies
Action / NotActionAPI operations such as s3:GetObject, wildcards allowed (s3:*)
Resource / NotResourceARNs the actions apply to (identity policies require them except for actions that don't support resource-level permissions)
ConditionExtra tests (IP, time, MFA, tags, encryption, Region)

Bucket-level actions like s3:ListBucket apply to the bucket ARN; object actions like GetObject apply to bucket/* — a classic source of errors.

Policy types

TypeAttached toGrants permissions?Notes
Identity-basedUser, group, roleYesAWS managed, customer managed, inline
Resource-basedS3, SQS, SNS, KMS, Lambda, secrets, etc.Yes, with a PrincipalEnables cross-account without role assumption
Permissions boundaryUser or roleNo — sets a maximumUsed to delegate admin safely
SCPOrganization root, OU or accountNo — sets a maximum for accountsAffects all principals in member accounts including root
Session policyPassed at AssumeRole/federationNo — further restricts sessionIntersection with role policies
ACLsS3, VPC (legacy / NACL)LimitedNot JSON

Policy evaluation logic

  1. Start with implicit deny.
  2. Look for any explicit Deny in all applicable policies (SCPs, boundaries, session, identity, resource). If found -> DENY.
  3. Organizations SCPs: if there is an SCP, the action must be allowed by it, otherwise DENY.
  4. Resource-based policy allow? (Same-account requests are allowed here if the principal ARN is named — no identity allow needed.)
  5. Permissions boundary, if present, must allow.
  6. Session policy, if present, must allow.
  7. Identity-based policy must allow.
  8. If none allow -> implicit DENY.
text
Effective permission (same account, identity policy path)
  = Identity policy  AND  Permissions boundary  AND  SCP  AND  Session policy
  (and no explicit Deny anywhere)

For cross-account requests both accounts must allow: the resource owner's resource policy (or role trust) and an identity policy in the caller's account.

Managed vs. inline

AWS managedCustomer managedInline
Maintained byAWSYouYou
ReusableYesYesNo — 1:1 with the identity
VersioningAWS updatesUp to 5 versions, rollbackNone; deleted with the identity
Best forCommon job functionsOrg-specific least-privilegeStrict 1:1 relationships

Conditions in action

Deny access outside approved Regions and without MFA

json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DenyOtherRegions",
      "Effect": "Deny",
      "NotAction": ["iam:*", "sts:*", "cloudfront:*", "route53:*", "support:*"],
      "Resource": "*",
      "Condition": { "StringNotEquals": { "aws:RequestedRegion": ["eu-west-1", "us-east-1"] } }
    },
    {
      "Sid": "DenyIfNoMfa",
      "Effect": "Deny",
      "Action": "ec2:TerminateInstances",
      "Resource": "*",
      "Condition": { "BoolIfExists": { "aws:MultiFactorAuthPresent": "false" } }
    }
  ]
}

Policy variables: give each user a private S3 folder

json
{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": ["s3:GetObject", "s3:PutObject"],
    "Resource": "arn:aws:s3:::acme-home/${aws:username}/*"
  }]
}

Attribute-based access control (ABAC)

Allow actions only when the principal's tag matches the resource's tag (e.g. aws:PrincipalTag/Project equals aws:ResourceTag/Project). ABAC lets one policy scale to many projects.

Resource-based policy example (cross-account S3)

json
{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Principal": { "AWS": "arn:aws:iam::444455556666:role/PartnerReader" },
    "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::acme-shared/*"
  }]
}

Tools for writing and validating policies

  • IAM Policy Simulator — test what a principal can do before deploying.
  • IAM Access Analyzer — policy validation, unused access findings and least-privilege policy generation from CloudTrail.
  • Access Advisor — last-accessed data to remove unused services.

Real World Example

Scenario — a bank enforces guardrails for 200 AWS accounts.

A bank gives each business unit its own AWS account under AWS Organizations. The security team must ensure no one can disable CloudTrail, use unapproved Regions or leave data unencrypted, yet developers must be able to create their own roles.

At the organisation level they apply SCPs: one denying cloudtrail:StopLogging and cloudtrail:DeleteTrail, and another denying all actions outside eu-west-1 and eu-central-1. Inside accounts, team leads can create IAM roles for applications, but every new role must carry a permissions boundary (enforced with an iam:PermissionsBoundary condition) that caps it to approved services and blocks IAM administration.

Application teams write customer managed identity policies with least privilege, and use ABAC with a CostCentre tag so a single policy covers every team's resources. S3 buckets holding shared data use resource-based policies with aws:PrincipalOrgID so any account in the organisation can read but nobody outside can. Policies are checked with Access Analyzer in the CI pipeline before deployment.

Architecture Diagram

Layers of policy evaluation
Architecture
AWS Cloud
Principaluser / role
Policy evaluation
SCPaccount guardrail
Permissions boundarymax for identity
Identity-based policyAllow / Deny
Resource-based policyPrincipal + Allow
Resourcebucket / queue / key

A request must pass every applicable layer; an explicit Deny anywhere ends the evaluation.

  1. 1The request starts as an implicit deny.
  2. 2Any explicit Deny in any applicable policy ends evaluation with a denial.
  3. 3SCPs and permissions boundaries must both allow the action, as guardrails around what can be granted.
  4. 4An identity-based or resource-based Allow then grants access; with no Allow the request is denied.

Best Practices

  • ✓Start from least privilege: grant only the actions and resources required, then widen if needed — use Access Analyzer to generate policies from CloudTrail.
  • ✓Prefer customer managed policies over inline, so they are reusable, versioned and easier to audit.
  • ✓Avoid "Action": "*" with "Resource": "*"; scope to specific ARNs and add conditions (MFA, source VPC endpoint, Region, org ID).
  • ✓Use explicit Deny guardrails (SCPs, boundaries) for things that must never happen, such as disabling CloudTrail or leaving the approved Regions.
  • ✓Use ABAC with tags to scale permissions without writing a policy per project.
  • ✓Validate with the IAM Policy Simulator and Access Analyzer before deployment; put policy checks into CI/CD.
  • ✓Use aws:PrincipalOrgID in resource policies instead of listing every account.
  • ✓Review unused permissions with Access Advisor and Access Analyzer unused-access findings; remove what isn't used.

Common Interview Questions

Exam Tips

SAA-C03 focus

  • Default deny -> explicit allow -> explicit deny overrides. Memorise this order.
  • SCPs and permission boundaries never grant permissions — they only set a maximum. The effective permission is the intersection.
  • SCPs affect all accounts' principals, including root, but not the management account.
  • Cross-account: both sides must allow (resource policy or role trust and caller's identity policy), unless a resource policy names the principal and same-account rules apply.
  • Know the size limits: managed 6,144; inline user 2,048, group 5,120, role 10,240 characters.
  • A customer managed policy can have up to 5 versions; inline policies have no versions.
  • "Allow only from corporate IP / VPC endpoint / with MFA / in one Region" -> Condition keys aws:SourceIp, aws:SourceVpce, aws:MultiFactorAuthPresent, aws:RequestedRegion.
  • "Test policies without making real calls" -> IAM Policy Simulator; "find resources shared externally" -> Access Analyzer.

Finished this lesson?

0 of 64 lessons done · 0% of the course