Sub topic 1
What AWS evaluates: the request and its context
Every call to AWS, whether from the console, the CLI, or an SDK, becomes a request. Before any policy is read, AWS gathers the facts about that request. The policies are then matched against those facts. This chapter covers what the facts are, because every later rule in this tutorial depends on them.
Prerequisites
This chapter assumes you have:
- Basic familiarity with AWS accounts, IAM users, groups, and roles.
- The ability to read JSON.
- A general idea of what an AWS API action and an ARN (Amazon Resource Name) are.
Authentication comes first
AWS handles each request in two steps. Authentication proves who is calling, usually through a signature made with access keys or temporary credentials. Authorization then decides whether that caller may do what it asked.
If authentication fails, no policy is evaluated. You get an error such as InvalidClientTokenId or SignatureDoesNotMatch. Policy evaluation only starts for a request that has already been authenticated.
The four parts of a request
Authorization looks at four things.
| Part | Meaning | Example |
|---|---|---|
| Principal | The user, role, or session making the call | `arn:aws:iam::111122223333:role/ReportWriter` |
| Action | The API operation requested | `s3:GetObject` |
| Resource | The object the action targets | `arn:aws:s3:::example-reports-bucket/2026/summary.csv` |
| Context | Extra facts about the request | Source IP, TLS use, tags, time |
The principal for a role call is the role's assumed-role session, not a person. The session carries the role's identity plus any session tags or session policy supplied when the role was assumed.
Request context
Context is a set of key-value pairs that AWS builds for each request. Policies read these pairs through the Condition element. The keys fall into a few groups:
- Global keys, prefixed
aws:, which exist for most requests. Examples areaws:SourceIp,aws:SecureTransport,aws:PrincipalArn,aws:PrincipalTag/key, andaws:CurrentTime. - Service keys, prefixed with the service name, such as
s3:prefixorec2:ResourceTag/key. - Tags on the principal and on the resource, which let you write rules like "a user may touch only resources with the same team tag".
Not every key is present on every request. A condition that tests a missing key does not match. This is a common source of surprising denies, and the Conditions chapter returns to it.
From request to decision
AWS collects every policy that applies to this principal, this resource, and this account. It then evaluates them together against the request. The result is always one of two outcomes: allow or deny.
A worked example
Suppose the role ReportWriter in account 111122223333 runs this command:
aws s3api get-object \
--bucket example-reports-bucket \
--key 2026/summary.csv \
summary.csvAWS builds this picture of the request:
- Principal: the
ReportWriterrole session. - Action:
s3:GetObject. - Resource:
arn:aws:s3:::example-reports-bucket/2026/summary.csv. - Context: the caller's IP address,
aws:SecureTransportset totruebecause the CLI uses HTTPS, and any tags on the role or the object.
Policies attached to the role, the bucket, and the organization are all checked against these four parts. A policy that names a different action or resource has no effect on this request. The next chapters explain how the matching policies combine.
Common mistakes
- Debugging policies when the real failure is authentication. Check the error name first.
- Assuming a context key is always present. Keys such as
aws:SourceIpcan behave differently when the call comes through an AWS service on your behalf. - Reading the wrong principal. A role call is evaluated as the role, not as the user who assumed it.
Exercise
A user calls s3:PutObject on arn:aws:s3:::example-reports-bucket/new.csv over HTTPS from a corporate IP address. Name the four parts of the request that AWS evaluates, and say which one holds the HTTPS fact.
Show answer
The four parts are the principal (the user), the action (s3:PutObject), the resource (the object ARN), and the context. The HTTPS fact is part of the context, as aws:SecureTransport set to true. The IP address is also context, as aws:SourceIp.