AWS IAM & multi-account security · Lesson 2 of 7 · 5 min read
Policies: types and structure
Policy document anatomy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ReadOrdersBucket",
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:ListBucket"],
"Resource": [
"arn:aws:s3:::acme-orders-prod",
"arn:aws:s3:::acme-orders-prod/*"
],
"Condition": {
"StringEquals": { "aws:PrincipalTag/team": "orders" },
"Bool": { "aws:SecureTransport": "true" }
}
}
]
}
Enlarge diagram
Swipe sideways to see all of it, or tap to open it full screen.
- Effect
Allow/Deny; Action (supports wildcards;NotActioninverts); Resource ARNs (NotResource); Principal only in resource-based and trust policies; Condition with operators (StringEquals,StringLike,ArnLike,IpAddress,Bool,NumericLessThan,DateGreaterThan,...IfExists,ForAnyValue:/ForAllValues:). - Note
s3:ListBucketapplies to the bucket ARN andGetObjectto object ARNs (/*) — a classic mistake. - Version "2012-10-17" is required for policy variables like
${aws:username}and${aws:PrincipalTag/team}.
Policy types
| Type | Attached to | Purpose |
|---|---|---|
| Identity-based (managed or inline) | Users, groups, roles | What the identity can do |
| Resource-based | Resources (S3 bucket policy, KMS key policy, SQS, SNS, Lambda, ECR, Secrets Manager) | Who can access this resource; enables cross-account without role assumption |
| Trust policy | Roles (a resource policy on the role) | Who can assume the role |
| Permissions boundary | Users/roles | Maximum permissions the identity can ever have — used to safely delegate role creation |
| SCPs (Service Control Policies) | Organization root, OUs, accounts | Maximum permissions for all principals in member accounts (not the management account) — guardrails |
| RCPs (Resource Control Policies) | Organization, OUs, accounts | Maximum permissions on resources in member accounts (e.g. no external access to S3) |
| Session policies | Passed when assuming a role/federating | Further restrict a single session |
| ACLs | Legacy S3/other | Avoid |
Managed policies: AWS managed (convenient, often too broad — AdministratorAccess, ReadOnlyAccess), customer managed (yours, versioned, reusable). Inline policies are embedded in one identity — use for strict one-to-one cases.
Enlarge diagram
Swipe sideways to see all of it, or tap to open it full screen.
Policy evaluation logic
For a request within one account:
- Explicit Deny anywhere (SCP, RCP, boundary, session, identity, resource) → denied. Deny always wins.
- Organizations SCPs/RCPs must allow it (if in a member account).
- Resource-based policy — if it allows the principal, it can grant access (within the same account) even without an identity policy (with caveats for roles/boundaries).
- Permissions boundary must allow it (if set).
- Session policy must allow it (if used).
- Identity-based policy must allow it.
- Otherwise implicit deny (default).
Effective permission = intersection of all the "maximum" policies (SCP ∩ RCP ∩ boundary ∩ session) with what identity/resource policies grant.
Enlarge diagram
Swipe sideways to see all of it, or tap to open it full screen.
Cross-account: the caller's identity policy must allow the action and the resource policy in the other account (or the trust policy of the role being assumed) must allow the caller. Both sides must say yes.
Enlarge diagram
Swipe sideways to see all of it, or tap to open it full screen.