0Pricing
AWS Security Academy · Lesson

Identity-Based versus Resource-Based Policies

Compare policies attached to identities with those on resources.

Identity-Based versus Resource-Based Policies is a free AWS Security Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AWS Security Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Two Places to Attach

Permissions in AWS come from policies attached in two places: to an identity (user, group, or role) or to a resource (like an S3 bucket or KMS key). Knowing which type applies, and how they combine, is essential for the exam because cross-account access depends entirely on this distinction.

Identity-Based Policies

An identity-based policy is attached to an IAM principal and defines what that principal can do. It has no Principal element because the principal is whoever it is attached to. These can be AWS-managed, customer-managed, or inline policies, and they are the most common way to grant permissions.

Resource-Based Policies

A resource-based policy is attached directly to a resource and includes a Principal element naming who is allowed access. Examples include S3 bucket policies, KMS key policies, SQS queue policies, and Lambda function policies. They specify both who (Principal) and what (Action) on that one resource.

Bucket Policy Example

This S3 bucket policy grants another account read access. The Principal names the trusted account, which only a resource-based policy can do.

{
  "Effect": "Allow",
  "Principal": { "AWS": "arn:aws:iam::444455556666:root" },
  "Action": "s3:GetObject",
  "Resource": "arn:aws:s3:::shared-data/*"
}

Same-Account Logic

Within a single account, identity-based and resource-based policies combine as a union: a request is allowed if either grants it (and nothing denies it). So an S3 object can be reached if the user's policy allows it or the bucket policy allows it. Either side opening access is enough.

Cross-Account Logic

For cross-account access the rule is stricter: both sides must allow it. The principal needs an identity-based policy permitting the action, and the resource-based policy in the other account must grant access to that principal. Missing either half denies the request. This is a heavily tested distinction.

No Resource Policy for Roles

Trust policies on roles are technically a kind of resource-based policy, which is why cross-account role assumption needs the trust policy plus the caller's sts:AssumeRole identity permission. Recognizing the trust policy as resource-based helps unify your mental model of how access is granted.

Which Services Support It

Not every service supports resource-based policies. Key ones that do: S3, KMS, SQS, SNS, Lambda, Secrets Manager, and ECR. When a service lacks resource policies, cross-account access must be granted through role assumption instead. The exam may test whether a chosen approach is even possible for a given service.

Choosing the Right Type

Use identity-based policies for general "this team can do these things" permissions. Use resource-based policies when you must grant access to a specific external principal, enable cross-account sharing on a supporting service, or set permissions that travel with the resource itself.

Auditing Both Sides

Because access can come from either side, auditing requires checking both. IAM Access Analyzer inspects resource-based policies to find resources shared externally or publicly. Policy simulation and last-accessed data help on the identity side. A complete review never looks at just one type.

Putting It Together

Same-account access is a union (either policy can allow), while cross-account access requires both the identity policy and the resource policy to allow. Identity policies have no Principal; resource policies do. Match the policy type to the scenario and remember which services even support resource-based policies.

Quick Check

Test your policy-type reasoning.

Recap

Identity-based policies attach to principals and have no Principal element; resource-based policies attach to resources and name a Principal. Same-account access is a union of the two; cross-account access requires both to allow. Only some services (S3, KMS, SQS, SNS, Lambda, Secrets Manager, ECR) support resource policies; otherwise use role assumption.

Frequently asked questions

Is the “Identity-Based versus Resource-Based Policies” lesson free?

Yes — the full text of “Identity-Based versus Resource-Based Policies” is free to read here on the web, and the AWS Security Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AWS Security Academy course, upgrade to CoddyKit PRO.

What will I learn in “Identity-Based versus Resource-Based Policies”?

Compare policies attached to identities with those on resources. You practise AWS Security Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start AWS Security Academy?

No prior experience is required. AWS Security Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Identity-Based versus Resource-Based Policies” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this AWS Security Academy lesson?

Yes. Every AWS Security Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Anatomy of an IAM Policy Document
  2. Identity-Based versus Resource-Based Policies
  3. The Policy Evaluation Decision Flow
  4. Conditions, Wildcards, and Policy Variables
← Back to AWS Security Academy