Security, cost and GPUs
How IAM decides allow or deny
The order cloud IAM uses to decide a request. Explicit deny always wins, identity and resource policies both count, and no allow means no access.
When a principal calls a cloud API, the cloud has to answer yes or no. It does that by collecting every policy that applies, then following a fixed set of rules in a fixed order. Once you know those rules, most "why was I denied?" questions answer themselves.
Concept
A principal is anything that can authenticate: a user, a machine role, a service account, or a federated login from an identity provider. A policy is a document that allows or denies actions on resources. A role is a named set of permissions that a principal can assume for a limited time.
The big idea
There are two shapes of policy, and both can matter.
| Shape | Attached to | Typical use |
|---|---|---|
| Identity-based | A user, group, role or service account | "This role may read objects in these buckets" |
| Resource-based | The resource itself: a bucket, queue, key or function | "This bucket accepts writes from that role" |
Within one account, an allow from either side can grant access. Across accounts, both sides normally have to allow. GCP leans more on identity bindings and less on separate resource policies, but the question is the same: identity, action, resource, and conditions.
Walking through a request
When a principal calls an API, AWS roughly does this:
- Authenticates the caller.
- Collects every applicable policy: identity, resource, permission boundaries, Service Control Policies (SCPs) and session policies.
- Applies explicit deny. Any deny anywhere blocks the call.
- Otherwise requires at least one allow. No allow means deny.
Here is a trace for one role reading one bucket:
| Step | What the policies say | Result |
|---|---|---|
| 1 | Identity policy allows s3:GetObject on the invoices bucket | An allow exists |
| 2 | Bucket policy has no matching deny | Keep going |
| 3 | An SCP above the account does not allow s3:GetObject | Call denied |
| 4 | Same SCP, but it now allows the action | Call allowed |
Permission boundaries and SCPs only subtract power. They are ceilings, not grants. Adding an allow to the role does nothing if an SCP above it blocks the action.
That is why "I attached AdministratorAccess" works instantly, and why a missing resource ARN fails silently until you read CloudTrail.
Common mistakes
- Looking for missing allows first. Check for explicit denies, SCPs and boundaries before you add anything.
- Treating an SCP as a grant. SCPs never give access. They only cap what member accounts can allow.
- Getting the resource ARN wrong. The policy looks right, the call still fails, and the only clue is in the audit log.
- Assuming the policy you attached is the one evaluated. Resource policies and boundaries count too.
Check yourself
- A role's identity policy allows
s3:GetObject, but an SCP above the account does not allow it. Is the call allowed? No. An SCP is a ceiling, so an allow inside the account cannot go past it. - A bucket policy explicitly denies a role, but the role's identity policy allows the same action. What happens? Denied. An explicit deny wins over any allow.
Key takeaways
- Explicit deny always wins.
- A request needs at least one allow, or it is denied by default.
- SCPs and permission boundaries are ceilings. They limit power and never grant it.
- Debug denials in order: principal, action, resource, then denies, then missing allows.
Further learning
Next, see how to shrink these policies safely in least privilege in practice.
Related
IAM and least privilege
How cloud identity works, why least privilege is a habit rather than a checkbox, and where the org-level guardrails sit. Start here for the map of IAM pages.
Authentication and authorization
Authentication proves who you are, authorization decides what you can do, and service-to-service calls need their own identity. The map for the rest of this topic.
Least privilege in practice
Grant the narrowest permissions a job needs, then tighten them with real usage data. Covers the practical loop, a worked example and conditions that scale.