Sub topic 1
How AWS Evaluates IAM Policies: The Request and Its Context
Prerequisites
Assume you know what an AWS account, IAM role, API action, and Amazon Resource Name (ARN) are. You should also be able to read basic JSON.
What AWS Evaluates
When an AWS service receives a request, authorization evaluates more than the requested action. It builds a request context containing:
- Principal: the IAM user, role, or session making the request.
- Action: the API operation, such as
s3:GetObject. - Resource: the target identified by an ARN.
- Context: extra facts such as the source IP address, VPC endpoint, TLS status, tags, and requested region.
AWS compares this context with every applicable policy. A policy statement applies only when its action, resource, principal, and conditions match the request.
The Policy Types at a Glance: Grant Versus Limit
Some policies grant permissions. Others restrict permissions that could otherwise be granted.
| Policy type | Attaches to | Main effect |
|---|---|---|
| Identity-based policy | User, group, or role | Grants permissions |
| Resource-based policy | Resource, such as an S3 bucket | Grants permissions to named principals |
| Permission boundary | User or role | Limits the permissions an identity policy can grant |
| Session policy | Temporary role session | Limits the session |
| Service control policy (SCP) | AWS account or organization unit | Limits accounts and principals in an organization |
A limiting policy does not grant access by itself. A request needs a matching allow from an applicable granting policy and must pass every applicable limit.
Reading a Policy Document
A statement commonly uses these fields:
{
"Effect": "Allow",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::example-reports-bucket/*"
}Effect is Allow or Deny. Action names the operation. Resource identifies the target. Resource-based policies also use Principal to identify who may access the resource. Condition adds requirements, such as requiring secure transport.
The Core Rule
AWS starts with an implicit deny. No request succeeds unless an applicable policy allows it. An explicit Deny always overrides an Allow, including an allow in another policy.
Exercise
A role policy allows s3:GetObject, but an applicable policy explicitly denies s3:GetObject. What is the result?
Show answer
The request is denied because an explicit Deny overrides every Allow.