AWS in 1 Min · Episode 28

Resource-based vs identity-based policies in AWS

vs identity-based policies. Watch the one-minute video, then read the details.

David Gomez1:18 video · 3 min read

"Permissions only live on users and roles." Resources have them too. In AWS, a policy can be attached to who is asking or to the thing being asked for, and both are checked on every request. Miss the second kind and you get surprises: a bucket that stays open to another account even after you cleaned up every user, or a cross-account setup that fails although the role looks perfect.

Identity-based policies: what can I do?

An identity-based policy is attached to an IAM user, group or role. It lists the actions that identity may perform, on which resources, under which conditions. It has no Principal element, because the principal is whoever the policy is attached to.

These are the policies most people mean when they say "IAM permissions". They can be managed (reusable, attached to many identities) or inline (embedded in one identity).

Resource-based policies: who can reach me?

A resource-based policy is attached to the resource itself. It always names a principal: the account, user, role or AWS service that is allowed in (or kept out). Common examples:

  • S3 bucket policies
  • SQS queue and SNS topic policies
  • Lambda function policies, which let another service invoke the function
  • KMS key policies
  • Role trust policies: the policy that says who may assume a role is a resource-based policy on the role

Only some services support them, and they are always inline: they live on that one resource. Don't confuse them with resource-level permissions, which simply means naming a specific ARN inside an identity-based policy.

How they combine

Inside one account, AWS evaluates both kinds together. If any applicable policy has an explicit Deny, the request is denied. Otherwise, one Allow is enough, and it doesn't matter whether it sits in the identity-based policy or the resource-based policy. That's why a user with no S3 permissions at all can still read a bucket whose policy names them.

There are stricter cases. A KMS key is controlled first by its key policy: IAM policies only count if the key policy lets the account use them. And a role's trust policy must always allow the caller in some form.

Across accounts, you need both:

  1. the resource-based policy in account B must allow the principal from account A, and
  2. an identity-based policy in account A must allow that principal to make the call.

If either half is missing, the request fails. A classic mistake is fixing only one side and then widening it in frustration, for example setting the bucket policy's principal to *. That doesn't solve a missing identity policy; it just opens the bucket to the world.

In every case, an explicit Deny wins over any Allow, in either policy.

Where AI fits

"Who may call our model?" is a permissions question, and the answer depends on the service:

  • Amazon Bedrock: invoking a model is controlled with identity-based policies. Give the application's role bedrock:InvokeModel on the specific model ARN it needs, rather than on every model. Bedrock's resource-based policies currently cover guardrails, not model invocation.
  • Amazon SageMaker AI endpoints: SageMaker doesn't support resource-based policies, so access is again an identity-based policy allowing sagemaker:InvokeEndpoint on that endpoint.
  • Lambda in front of a model: if a function wraps your model call, the function's resource-based policy decides which services or accounts may invoke it.

For cross-account use of a model, the practical pattern is a role in the model's account that the other account assumes, since there's no resource policy on the model to open.

Quick recap

  • Identity-based policies say what an identity can do; resource-based policies say who can reach a resource.
  • In one account, one Allow is usually enough; across accounts, both sides must allow.
  • An explicit Deny always wins, and model access is mostly an identity-side decision.
AWS in 1 Min #28 · 1:18

Need an AWS expert on your team?

I'm David, an AWS expert and fractional cloud consultant. I work alongside your team to run your cloud and infrastructure: architecture, security, cost and day-to-day operations. You get senior AWS experience when you need it, without the cost of a full-time hire.

  • Architecture reviews and a clear plan for what to fix first
  • Security hardening: IAM, networking, audits
  • Lower AWS bills without slowing your team down
  • Hands-on help with AI workloads on AWS