You already know that policies are the documents that define permissions in AWS. But there are two ways to apply them, depending on where you attach them: to an identity or to a resource. Understanding the difference will help you read and write permissions correctly, and solve the classic mystery of “why isn’t this permission working?”

Anatomy of a Policy (Quick Review)

An IAM policy is a JSON document. Its central piece is the statement, which answers:

{
  "Effect": "Allow",
  "Action": "s3:GetObject",
  "Resource": "arn:aws:s3:::informes-2026/*"
}
  • Effect: Allow (permit) or Deny (deny).
  • Action: what can be done (s3:GetObject = read S3 objects).
  • Resource: on which resource (identified by its ARN, the unique identifier of any resource in AWS).

This policy says: “Allow the action read objects on the objects in the informes-2026 bucket.” Don’t worry about memorizing the syntax; the important thing is to understand the concept.

The Two Ways to Apply Permissions

Identity-based Policies

They are attached to an identity: a user, a group, or a role. They answer the question:

“What can THIS identity do?”

Example: You attach a policy to the user María that says “she can read from the informes-2026 bucket.” The permission travels with María: wherever she acts, she can read that bucket.

This is the most common way. When you grant permissions to your users and roles, you normally use identity-based policies.

Resource-based Policies

They are attached to the resource itself: an S3 bucket, an SQS queue, a Lambda function… They answer the question:

“Who can access THIS resource?”

Example: You attach a policy to the informes-2026 bucket that says “the partner company’s account can read my objects.” The permission travels with the bucket: it defines who can enter it.

You already saw an example in Chapter 5: S3 bucket policies are resource-based policies.

The Analogy That Makes It Clear

Building Analogy:

  • An identity-based policy is like what your employee card can open. You carry it with you; it defines which doors you can enter.
  • A resource-based policy is like the list of authorized people posted on the door of a specific room. It defines who can enter that particular room.

Sometimes, to enter a room, both must match: your card must allow you to open that door and your name must be on the room’s list.

When Is Each Used?

Situation Type of Policy
Granting permissions to your own users/roles Identity-based (the usual)
Allowing another AWS account to access your resource Resource-based
Controlling who accesses an S3 bucket, SQS queue, Lambda Resource-based
General permissions for a development team Identity-based (via groups)

The star case for resource-based policies is cross-account access: when someone from another AWS account needs to access something of yours, the resource-based policy is what allows it, because it applies to the resource regardless of which account the accessor comes from.

How They Combine: The Evaluation Logic

When someone tries to do something, AWS evaluates all applicable policies (identity and resource-based) with these rules, in this order:

  1. By default, everything is denied. If nothing allows it, it’s denied.
  2. An explicit Allow grants the permission (it can come from the identity or resource policy).
  3. An explicit Deny ALWAYS wins. If any policy says “deny,” it’s denied, even if another says “allow.”
Is there an explicit Deny?  ──Yes──► DENIED (always wins)
        │ No
        ▼
Is there an explicit Allow?  ──Yes──► ALLOWED
        │ No
        ▼
              DENIED (default denial)

Mental rule:Deny beats Allow, and without Allow there is no permission.” This rule solves almost all AWS permission mysteries.

Typical mystery example: “I gave María permission to read the bucket, but she can’t.” Possible causes: there’s an explicit Deny somewhere (which wins), or the resource policy (bucket) doesn’t include her, or the Allow is missing from her identity. Knowing the evaluation logic, you know where to look.

A Note: Managed vs Inline Policies

To finish, two ways to organize policies (not to be confused with identity/resource):

  • Managed: reusable policies you attach to multiple identities. AWS offers many predefined ones (like AmazonS3ReadOnlyAccess), and you can create your own. Recommended because they’re reusable and easy to maintain.
  • Inline: policies written directly inside a single identity. Useful for very specific permissions for a single user or role.

What You Should Remember

  • A policy defines permissions with Effect (allow/deny), Action (what), and Resource (on what, via ARN).
  • Identity-based: attached to a user/group/role → “what can this identity do?” It’s the most common.
  • Resource-based: attached to the resource (bucket, queue…) → “who can access this resource?” Key for cross-account access.
  • Evaluation logic: everything denied by default, an Allow grants, and an explicit Deny always wins.
  • “Deny beats Allow, and without Allow there is no permission” solves most doubts.

In the next subchapter we’ll look at two pillars of access security: multi-factor authentication (MFA) and temporary credentials (STS).

Cloud, AWS & Terraform — From Zero to Expert

Chapter 1 · What is cloud computing

Chapter 2 · The cloud market and major providers

Chapter 3 · Regions, availability zones and edge

Chapter 4 · Compute: EC2

Chapter 5 · Storage: S3

Chapter 6 · Networking: VPC

Chapter 7 · Identity and access: IAM

Chapter 8 · Managed databases

Chapter 9 · Why Infrastructure as Code

Chapter 10 · HCL: the Terraform language

Chapter 11 · Providers and state

Chapter 12 · Your first real infrastructure in Terraform

Chapter 13 · Load balancing and auto scaling

Chapter 14 · Serverless with Lambda

Chapter 15 · Messaging and events

Chapter 16 · Content delivery and DNS

Chapter 17 · Containers on AWS

Chapter 18 · Modules: reuse and composition

Chapter 19 · Workspaces and environment management

Chapter 20 · Remote backends and locking

Chapter 21 · Infrastructure testing

Chapter 22 · Terraform in CI/CD

Chapter 23 · Defense in depth

Chapter 24 · Observability: logs, metrics and traces

Chapter 25 · Cost optimization

Chapter 26 · High availability and disaster recovery

Chapter 27 · AWS Well-Architected Framework

Chapter 28 · Serverless architectures at scale

Chapter 29 · Data platforms on AWS

Chapter 30 · Multi-account and landing zones

Chapter 31 · Platform Engineering and Internal Developer Platform

Chapter 32 · Relevant AWS certifications

Chapter 33 · Projects to consolidate what you've learned

Chapter 34 · Resources and community

© Copyright 2024. All rights reserved