← Back to blogs
2026-09-14 | 0gulcandogan | Published on AWS Builder| 13 min read

IAM Tips: Roles, Policies, and Boundary-Based Access

IAM Tips: Roles, Policies, and Boundary-Based Access

1. Introduction

IAM (Identity and Access Management) is where AWS answers the question: "who can access what, and how much." It sounds simple, but the root cause of most security incidents is actually a poorly designed IAM setup — either a permission that's too broad, a leaked access key, or a "temporary" access grant that became permanent.

This article focuses on three areas: using roles effectively, what to watch for when writing policies, and permission boundaries combined with tag-based access control. These are the three areas that make the biggest difference in day-to-day IAM usage.


2. Use Roles Instead of Users

Creating an IAM User seems like the easiest path at first — open a user, hand them an access key, let them get to work. But this approach carries a real cost: access keys are long-lived, static credentials. Once created, they stay valid until someone forgets them somewhere — in a config file, a GitHub repo, a CI/CD pipeline. If they leak, whoever obtained them can do whatever that permission allows until you notice.

IAM Role solves this problem at the root, because a role isn't tied to an identity — it's tied to a task. Whoever assumes the role — an EC2 instance, a Lambda function, another AWS account, or a user — receives temporary credentials. These credentials are typically valid for anywhere from 15 minutes to a few hours, then automatically expire. So even if they leak, the "key" the attacker holds stops working shortly after.

In practice, the rule becomes: if an application, service, or automation needs to access AWS, never hard-code a static access key there — attach a role instead. If you attach an IAM Role to an EC2 instance, the code running on that instance can access AWS APIs without managing any credentials at all — AWS handles the credential rotation for you in the background.

The same logic applies to human users: if a user needs access to different accounts or different permission levels, letting them switch between roles (role switching / assume role) is far cleaner than opening a separate IAM User in every account. The user logs in with a single identity, temporarily assumes the role they need, and that permission ends once the task is done.

In short: IAM User + access key = persistent risk. IAM Role + temporary credentials = controlled and measurable risk.


3. What to Watch For When Writing Policies

Whether it's a role or a user doesn't matter — the real power always lies in the policy. If the policy is written incorrectly, the identity underneath it carries excessive permissions no matter how "temporary" or "secure" it seems.

The Principle of Least Privilege

This is IAM's golden rule: grant an identity the minimum permissions it needs to do its job — no more, no less. In practice, this means the opposite of "grant broad access first, then narrow it down." The right approach is to start narrow and expand permissions only as real need arises. AWS's IAM Access Analyzer tool analyzes what actions a role actually uses based on CloudTrail logs, and helps you identify unused permissions — a great tool for narrowing your policies over time.

The Danger of Wildcards (*)

{
  "Effect": "Allow",
  "Action": "*",
  "Resource": "*"
}

Alarm bells should go off whenever you see this line. Action: "*" means granting permission to do everything that service (or all services) can do — delete, create, edit, all of it. Likewise, Resource: "*" means this permission applies to every resource in the account. Unless there's a genuine need, keep both the Action and Resource fields specific — for example, s3:GetObject scoped to a specific bucket ARN.

AWS Managed vs. Customer Managed vs. Inline Policy

There are three policy types, each with a different use case:


4. Permission Boundaries and Tag-Based Access Control

What Is a Permission Boundary?

Think of a permission boundary as an "upper limit" or "ceiling." The regular policies attached to a role or user define what it can do, while a permission boundary places a ceiling on top of that: no matter what the identity's policies say, it can never exceed this ceiling.

The classic use case for this is delegation scenarios. Say you want to let a development team create their own IAM roles — but you don't want that team to be able to create a role with AdministratorAccess. This is exactly where a permission boundary comes in: you grant the team permission to create roles, but a permission boundary is automatically applied to every role they create. No matter how broad a policy the team writes, the result is always capped by this boundary.

Effective Permissions = (User's Policy) ∩ (Permission Boundary)

In other words, the real permission is the intersection of two sets — no matter how broad one is, if the other is narrow, the result stays narrow.

Tag-Based Access Control

As the number of resources grows, writing a separate policy for each one becomes unsustainable. This is where tag-based access control comes in: you attach meaningful tags to resources (EC2, S3, etc.) — like Environment: Prod or Team: Finance — and write your policies with conditions based on those tags.

For example, you can set a rule like: "A user can only access resources whose Team tag matches their own." This way, when a new resource is created, as long as it carries the right tag, it automatically falls under the correct access rules — you don't have to update the policy every time.

"Condition": {
  "StringEquals": {
    "aws:ResourceTag/Team": "${aws:PrincipalTag/Team}"
  }
}

The biggest advantage of this approach is scalability: even if the number of resources grows from 10 to 10,000, the number of policies stays constant — because the rule is tied to the resource's tag, not the resource itself.


5. Summary — Key Concepts

Original: AWS Builder Center

Thanks for reading

If this write-up helped, consider sharing it or exploring more of the log.

← All posts About the author