Course contentsShow
← Security
Lesson 1704 of 3,05235. Cloud Security - IAMFree lesson

Identity-Based vs Resource-Based Policies

Understanding policies attached to identities versus policies attached to resources and when to use each approach.

Identity-Based vs Resource-Based Policies

You'll learn: The critical difference between attaching permissions to who you are versus what you're accessing, and when each approach makes sense.

Two Ways to Grant Access

Cloud IAM offers two fundamental policy attachment models:

Identity-based policies attach to identities (users, groups, or service accounts). They answer: "What can this identity do?" Think of these as permissions carried in your wallet—they travel with you everywhere.

Resource-based policies attach directly to resources (like storage buckets, databases, or functions). They answer: "Who can access this specific resource?" These are like door locks—the permission lives at the destination.

When to Use Each Approach

Identity-Based Policies

Use when managing permissions for people or applications:

  • Granting a developer group read access to multiple resources
  • Defining what a service account can do across your infrastructure
  • Centrally managing user permissions

Analogy: Like a company badge listing all rooms you can enter.

Resource-Based Policies

Use when defining who can access a specific resource:

  • Allowing another cloud account to access your storage bucket
  • Granting a public endpoint permission to invoke a specific function
  • Cross-account resource sharing
  • When the resource must control its own access (defense in depth)

Analogy: Like a safe with its own combination—access rules live with the asset itself.

The Key Distinction

Both policies evaluate during access decisions. A request succeeds if either the identity-based policy allows it or the resource-based policy permits it (assuming no explicit denies). Resource-based policies are especially powerful for cross-account scenarios where you can't attach policies to external identities.

Key Takeaway: Identity-based policies define what an identity can do across resources; resource-based policies define who can access a specific resource. Use identity-based for managing people/service permissions, resource-based for controlling access to specific assets or enabling cross-account sharing.