Sub topic 2
The policy types at a glance: grant versus limit
This chapter gives you a map of the IAM policy types before later chapters go into each one. It assumes you know what AWS accounts, IAM users, groups and roles are, can read JSON, and know roughly what an API action and an ARN are.
The one question that sorts every policy type
Every policy type answers one question: does it grant permissions, or does it only limit them?
- A granting policy can produce an Allow that makes a request succeed.
- A limiting policy can never make a request succeed by itself. It sets a ceiling, and anything outside the ceiling is denied even if some other policy allows it.
Most AccessDenied surprises come from mixing these two roles up. A permission boundary, for example, looks like an Allow policy, but it grants nothing. An SCP also looks like an Allow policy, and it grants nothing either.
The policy types
| Policy type | Attached to | Grants or limits | Typical purpose |
|---|---|---|---|
| Identity-based policy | IAM user, group or role | Grants | Say what a principal may do |
| Resource-based policy | A resource, such as an S3 bucket or a KMS key | Grants | Say who may use this resource, including other accounts |
| Permission boundary | IAM user or role | Limits | Cap what identity policies can give that principal |
| Session policy | A temporary session, passed at role assumption or federation | Limits | Narrow one session below the role's normal permissions |
| Service control policy (SCP) | Organization root, organizational unit (OU) or account | Limits | Cap every principal in the affected accounts |
| Resource control policy (RCP) | Organization root, OU or account | Limits | Cap what can be done to resources in the affected accounts |
| VPC endpoint policy | A VPC endpoint | Limits | Cap what can pass through that network path |
Two details in the table matter later:
- Resource-based policies are special. They are the only granting policies that name a principal, because they are attached to the resource and not to the caller. In some cases they can grant access without any identity policy. Same-account and cross-account requests differ on this point, and a later chapter covers it.
- SCPs and RCPs do not apply to everyone. SCPs affect principals in member accounts. They do not affect the Organizations management account, and they do not affect service-linked roles. Some policy types also have gaps for specific cases, so check the documentation before relying on them as a universal control.
Where each policy sits
The diagram shows where each type attaches, and which ones sit on the caller's side or the resource's side.
Granting policies in detail
Identity-based policies
An identity-based policy is attached to a user, group or role. It has no Principal element, because the principal is whoever the policy is attached to. This policy lets its holder read and write objects in one bucket:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ReadWriteReports",
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::example-reports-bucket/*"
}
]
}Attach it to a role and every session of that role gets those two actions on objects in that bucket, unless a limiting policy removes them.
Resource-based policies
A resource-based policy lives on the resource and names who may use it. It must contain a Principal element. This bucket policy in account 111122223333 names a role from account 222233334444:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowReportReaderRoleFromOtherAccount",
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::222233334444:role/ReportReader" },
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::example-reports-bucket/*"
}
]
}For this cross-account request to work, the role's own identity policy in account 222233334444 must also allow s3:GetObject. Both sides must agree when the request crosses an account boundary. Inside a single account, either side alone is usually enough. The chapter on same-account and cross-account requests explains why.
Limiting policies in detail
Permission boundaries
A permission boundary is a managed policy that you set on a user or role. It does not grant anything. It defines the maximum the identity policies can give. The effective permissions are the overlap between the identity policy and the boundary.
Suppose a role has an identity policy that allows s3:* and ec2:DescribeInstances, and this boundary:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "BoundaryCeiling",
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::example-reports-bucket/*"
}
]
}The effective permissions are only s3:GetObject and s3:PutObject on objects in that bucket. ec2:DescribeInstances is removed because the boundary does not mention it. The rest of s3:* is removed for the same reason.
Session policies
A session policy is passed inline when you create a temporary session, for example with AssumeRole or GetFederationToken. The session gets the overlap of the role's permissions and the session policy. Use it to hand a narrower set of permissions to one caller, such as a single customer or a single job, without creating a separate role for each. A session policy can never expand the role.
SCPs and RCPs
A service control policy applies to the principals in the accounts it covers. A resource control policy applies to certain resources in those accounts. Neither grants anything. An SCP that allows s3:* does not give any user S3 access. It only says S3 actions are not blocked at the organization level. Principals still need their own grant from an identity or resource policy.
VPC endpoint policies
A VPC endpoint policy controls what can pass through one endpoint, such as the S3 gateway endpoint. It limits requests that use that network path. It does not look at who owns the account, only at the path the request takes.
Explicit deny works in every policy type
Any of these policies can contain "Effect": "Deny", and a matching Deny always wins. This is how you write a guardrail that no Allow can override:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyInsecureTransport",
"Effect": "Deny",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::example-reports-bucket",
"arn:aws:s3:::example-reports-bucket/*"
],
"Condition": { "Bool": { "aws:SecureTransport": "false" } }
}
]
}This statement denies any request to the bucket that does not use TLS. It can sit in a bucket policy, an SCP or an RCP, and the result is the same: no Allow elsewhere can override it. The next chapters cover the evaluation rule in full.
Choosing the right type
Pick the policy type by the job you need done:
- Give a principal permissions inside your account: use an identity-based policy.
- Let a specific outside account or principal use one resource: use a resource-based policy, and remember the other account's identity must also allow the action.
- Let team leads create roles without letting them escalate privileges: require a permission boundary on every role they create.
- Give one caller a smaller slice for a short time: use a session policy.
- Enforce a rule across many accounts, such as limiting regions: use an SCP.
- Protect resources from outside access across the organization: use an RCP.
- Control what leaves through a network path: use a VPC endpoint policy.
Checking the combined result
The IAM policy simulator evaluates the policies attached to a principal, including its permission boundary, for the actions and resources you name. This command asks how a role would fare on two actions against one object:
aws iam simulate-principal-policy \
--policy-source-arn arn:aws:iam::111122223333:role/ReportWriter \
--action-names s3:GetObject s3:PutObject \
--resource-arns arn:aws:s3:::example-reports-bucket/2026/summary.csvTreat the output as a check on your reasoning, not as the final authority. It does not always reflect every policy type or every condition value from a real request, so a real call can still differ.
Common mistakes
- Treating a boundary or SCP as a grant. Neither can allow anything by itself.
- Expecting a resource policy to be enough across accounts. The calling account's identity must also allow the action.
- Forgetting that session policies only narrow. They cannot add permissions to a role.
- Assuming SCPs affect the management account. They do not.
- Trying to "fix" a deny by adding an Allow. An explicit Deny in any applicable policy still wins.
Exercise
A role has an identity policy that allows s3:* and ec2:DescribeInstances. Its permission boundary allows only s3:GetObject on arn:aws:s3:::example-reports-bucket/*. The role's organization has an SCP that allows s3:* and ec2:*. Which of these calls succeed: s3:GetObject on example-reports-bucket/a.csv, s3:PutObject on the same bucket, and ec2:DescribeInstances? Explain which policy blocks each failure.
Show answer
Only s3:GetObject on the bucket object succeeds. It is allowed by the identity policy, inside the boundary, and not blocked by the SCP. s3:PutObject fails because the boundary does not include it, even though the identity policy and SCP allow it. ec2:DescribeInstances fails for the same reason: the boundary does not include it. The SCP's allow for ec2:* does not rescue it, because an SCP grants nothing.
Exercise
Sort these into "can grant access" and "only limits access": identity-based policy, permission boundary, resource-based policy, session policy, SCP, VPC endpoint policy.
Show answer
Can grant: identity-based policy and resource-based policy. Only limit: permission boundary, session policy, SCP and VPC endpoint policy.