AWS Builder Center
IAM Tips: Roles, Policies, and Boundary-Based Access

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

A practical guide to the three IAM areas that make the biggest difference in multi-account AWS environments: moving from static access keys to temporary role-based access, writing policies around least privilege, and using permission boundaries with tag-based access control for safe delegation. Less theory, more concrete rules and code examples you can actually use.

Cloud Security Engineer | Metal Riff Master 🎸

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:
  • AWS Managed Policy: Pre-built policies provided by AWS for general scenarios (e.g.  AmazonS3ReadOnlyAccess ). Great for getting started quickly, but you can't fine-tune them for your specific environment — and when AWS updates them, they change automatically, which can sometimes catch you off guard.
  • Customer Managed Policy: Policies you write yourself, versioned, and attachable to multiple roles/users. This is the most commonly preferred approach in real-world setups, because it's reusable and you retain full control.
  • Inline Policy: Embedded directly into a single user, group, or role, and cannot be attached anywhere else. Makes sense for a very specific, one-off need, but becomes a management nightmare if it spreads — you can't know what's granted where without checking each identity individually. Customer Managed Policies wherever possible, treat AWS Managed Policies as a starting point, and reserve Inline Policies for genuinely exceptional cases.



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

  • Static credentials = persistent risk. Prefer roles and temporary credentials over access keys wherever possible.
  • Least privilege isn't a destination, it's a continuous habit — start narrow, expand only as real need arises.
  • Whenever you see  Action: "*"  or  Resource: "*" , stop and question it — is this permission really necessary at this scope?
  • Customer Managed Policies are more sustainable than Inline Policies in most scenarios.
  • A permission boundary is a guarantee: no matter how broad the granted policy is, the result can never exceed this ceiling — the safe way to delegate.
  • Tag-based access control prevents policy sprawl as resource count grows — the rule attaches to the tag, not the resource.
  • Run IAM Access Analyzer regularly — unused permissions are open doors waiting to be closed.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article