AWS Learning Journey

AccessDenied? The IAM Mental Model That Makes AWS Permissions Finally Click

Every AWS request answers one question: who can do what, to which resource? Learn to read that answer, and AccessDenied stops being a mystery.

11 min read · 2018 words
AWSAWS IAMCloud SecurityDevOpsCloud Computing
AccessDenied? The IAM Mental Model That Makes AWS Permissions Finally Click cover image

AWS from Zero to Production — Phase 2, Part 1 of 6 · See the full series roadmap


You run a command. AWS replies:

An error occurred (AccessDenied) when calling the PutObject operation:
User: arn:aws:sts::111122223333:assumed-role/app-role/session
is not authorized to perform: s3:PutObject on resource: arn:aws:s3:::my-bucket/report.csv

Most people react by adding more permissions until the error goes away. Sometimes they add "Action": "*". It works — and it quietly turns a small bug into a large security risk.

The real fix is understanding how AWS decides. Every request is evaluated against a small set of rules. Once you know them, you can read an AccessDenied message like a sentence and fix it precisely.

That system is AWS Identity and Access Management (IAM). It’s the most important service in AWS, because every other service depends on it.

What you’ll walk away with


The one sentence that explains IAM

Every request to AWS boils down to:

Can this principal perform this action on this resource, under these conditions?

IAM’s job is to answer “yes” or “no.” Everything else in this article is detail on how it reaches that answer.

Reading an ARN

ARNs uniquely identify AWS resources:

arn:aws:s3:::my-bucket/report.csv
arn:aws:iam::111122223333:role/app-role
arn:aws:ec2:eu-west-1:111122223333:instance/i-0abc123def4567890
     |   |      |           |            |
     |   |      Region      Account ID   Resource
     |   Service
     Partition

Some services, like S3 and IAM, leave the Region or account empty because their resource names are global.


Identities: who can make requests

The root user

You met it in Phase 1: complete access, locked away with MFA, used only for a few account-level tasks. It’s not part of day-to-day IAM design.

IAM users

An IAM user is a long-lived identity in one account, with its own credentials:

Those credentials don’t expire on their own. That’s the problem.

Engineer’s note: AWS now recommends that people sign in through IAM Identity Center or another identity provider, and that workloads use roles. IAM users are for the few cases that genuinely need long-term credentials, such as some third-party tools that can’t assume roles.

IAM groups

A group is a collection of IAM users. Attach policies to the group, and every member inherits them.

IAM roles

A role is an identity with permissions but no long-term credentials. Instead, a trusted principal assumes the role and receives temporary credentials that expire automatically.

Roles are used by:

Rule of thumb: If something runs code or automation, it should use a role. If it’s a person, they should sign in through IAM Identity Center, which gives them a role behind the scenes.


Policies: the rules themselves

A policy is a JSON document that grants or denies permissions.

Anatomy of a policy

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ReadReports",
      "Effect": "Allow",
      "Action": [
        "s3:GetObject",
        "s3:ListBucket"
      ],
      "Resource": [
        "arn:aws:s3:::my-reports-bucket",
        "arn:aws:s3:::my-reports-bucket/*"
      ],
      "Condition": {
        "Bool": { "aws:SecureTransport": "true" }
      }
    }
  ]
}

Watch out: s3:ListBucket applies to the bucket ARN, while s3:GetObject applies to objects inside it (bucket/*). Mixing these up is one of the most common causes of AccessDenied with S3.

Identity-based policies

Attached to a user, group, or role. They say what that identity can do.

The example above is an identity-based policy. Notice there’s no Principal element — the principal is whoever the policy is attached to.

Resource-based policies

Attached to a resource, such as an S3 bucket, a KMS key, an SQS queue, or a Lambda function. They say who can access that resource, so they include a Principal:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowAnalyticsAccountRead",
      "Effect": "Allow",
      "Principal": { "AWS": "arn:aws:iam::444455556666:role/analytics-role" },
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::my-reports-bucket/*"
    }
  ]
}

This bucket policy lets a role in another account read objects. Resource-based policies are a key tool for cross-account access.

Important: A role’s trust policy — which says who can assume it — is also a resource-based policy. The role is the resource. We’ll go deep on trust policies in Part 2.

Three ways to manage policies

Engineer’s note: Start from AWS managed policies to learn and prototype. Move to customer managed policies, scoped to specific resources, before anything reaches production.


How AWS decides: policy evaluation logic

This is the part that makes AccessDenied make sense.

The three core rules

  1. Everything is denied by default. If nothing allows a request, it’s denied. This is called an implicit deny.
  2. An explicit Deny always wins. If any applicable policy says Deny, the request is denied — no matter how many policies allow it.
  3. Otherwise, you need an explicit Allow. At least one applicable policy must allow the request.

The simplified decision flow

Request arrives
      |
      v
Any explicit Deny in any applicable policy? --- yes ---> DENIED
      |
      no
      v
Do organization guardrails (SCPs, RCPs) allow it? --- no ---> DENIED
      |
      yes
      v
Does a permissions boundary or session policy
apply, and does it block the action? --- yes ---> DENIED
      |
      no
      v
Does an identity-based or resource-based
policy explicitly Allow it? --- no ---> DENIED (implicit)
      |
      yes
      v
   ALLOWED

This is a simplified view. AWS’s full evaluation logic covers more edge cases, but this flow explains the vast majority of real-world decisions. Permissions boundaries and session policies are covered in Part 2.

Same account vs. cross-account

Reading the error again

Go back to the error at the top of this article:

Now you know exactly what to check: does app-role have an Allow for s3:PutObject on my-bucket/*, and is there an explicit Deny anywhere — in an SCP, the bucket policy, or a boundary?

Engineer’s note: Many AccessDenied messages now say which kind of policy blocked the request, such as “with an explicit deny in a service control policy.” Read the whole message before changing anything.


Least privilege

Least privilege means granting only the permissions needed to do a task — no more.

In practice:


Credentials: long-term vs. temporary

MFA

Multi-factor authentication adds a second proof of identity, such as an authenticator app, a security key, or a passkey. Use it on every human sign-in. Policies can even require it with the aws:MultiFactorAuthPresent condition.

Access keys

An access key is a pair used to sign API requests:

Long-term access keys never expire on their own. Anyone who copies them — from a laptop, a Git commit, a CI log — can use them until someone notices.

Temporary credentials

Temporary credentials include an access key ID (starting with ASIA), a secret, a session token, and an expiration time. They’re valid for minutes or hours, then stop working automatically.

You’ve already used them: aws configure sso in Phase 1 gave you temporary credentials.

AWS Security Token Service (STS)

STS is the service that issues temporary credentials. Its key operations:

Here’s what assuming a role looks like from the CLI:

aws sts assume-role \
  --role-arn arn:aws:iam::111122223333:role/read-only-role \
  --role-session-name alice-debugging
{
  "Credentials": {
    "AccessKeyId": "ASIAEXAMPLEID",
    "SecretAccessKey": "wJalr...EXAMPLE",
    "SessionToken": "IQoJb3JpZ2luX2Vj...",
    "Expiration": "2026-10-31T13:00:00Z"
  },
  "AssumedRoleUser": {
    "AssumedRoleId": "AROAEXAMPLEID:alice-debugging",
    "Arn": "arn:aws:sts::111122223333:assumed-role/read-only-role/alice-debugging"
  }
}

The big idea: Modern AWS security is built on roles and temporary credentials. By the end of Phase 2, you’ll deploy from GitHub to AWS without a single long-term key.


Common mistakes


Key takeaways


Quick self-check

Test yourself before moving on:

  1. Can you use an IAM group as the Principal in a bucket policy?
  2. One policy allows s3:DeleteObject, and another applicable policy explicitly denies it. What happens?
  3. A policy allows s3:ListBucket on arn:aws:s3:::my-bucket/*, but listing fails. Why?
  4. An access key ID starts with ASIA. Is it long-term or temporary?

Answers

  1. No. Groups aren’t identities. Use the users or, better, a role.
  2. Denied. An explicit deny always overrides an allow.
  3. s3:ListBucket applies to the bucket ARN, arn:aws:s3:::my-bucket, not to the objects inside it.
  4. Temporary. It came from STS and has a session token and an expiration.

What’s next

In Part 2, we go beyond the basics: role trust policies, cross-account access, permissions boundaries, conditions, attribute-based access control, and the tools that keep permissions tight over time.

What’s the most confusing AccessDenied error you’ve ever hit? Share it in the comments.


Share this article

LinkedIn post draft