iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🐷

Beyond Beginner: Why AWS Experts Don't Use IAM Users—Understanding 'AssumeRole' That 90% of People Don't Know

に公開
2026/01/27

*This page contains promotions.

What you will learn in this article:

  1. An IAM user is a "permanent employee ID card." If it leaks, it's game over.
  2. An IAM role is a "loaner hat." You only have permissions while you are wearing it.
  3. "AssumeRole" is the action of "putting on (transforming into)" the hat.
  4. Professionals don't use employee ID cards; they operate by "putting on a hat" only when necessary.

Introduction: The Despair of "Access Denied"

The error you will see most frequently when working with AWS is: User: xxx is not authorized to perform: s3:ListBuckets.

"I should have administrator privileges!" "I pasted the JSON exactly as instructed!"

Many engineers lose time stuck in front of this "permissions puzzle." Today, we will master IAM (Identity and Access Management), the cornerstone of AWS security, without using any difficult terminology, by comparing it to "playing dress-up."

[Update]
The "diagrams" in this article have been praised for being easy to understand!
If you would like to see diagrams for other services, please take a look at the following book, which illustrates major AWS services!
(Currently, a free preview of some parts is available👇)

https://zenn.dev/miyaco_log/books/d26a6fe78b33e9

1. Only 4 Characters

IAM is confusing because there are many similar terms. Let's first replace these with a "normal company" analogy.

AWS Term Corporate Analogy Characteristics
IAM User Employee (Individual) A "living human" with an ID and password. Tanaka-san, Suzuki-san.
IAM Group Department Sales Dept, Development Dept. A box to manage permissions in bulk.
IAM Policy Operations Manual A permit that says "You are allowed to see S3" or "You are allowed to delete EC2."
IAM Role Job-title Hat (Most Important) A "helmet" or "armband" that anyone can wear.

Beginner's mistake: Trying to do everything with "Employees (Users)."
When you want to "access S3 from EC2," do you embed "access keys (employee ID cards)" inside the EC2 instance? That is just as dangerous as leaving an employee ID card in the server room.

That is where the "IAM Role (hat)" comes in.

2. The IAM Role is a "Magic Hat"

An IAM role is not a specific "person." It is an "item that allows you to exercise permissions only while you are wearing that hat."

  • IAM User: "I am Tanaka" (You always have the certificate)
  • IAM Role: "I am currently an administrator" (Valid only while you are wearing the hat)

In AWS terminology, the action of "putting on the hat" is called AssumeRole.

▼ [Diagram] Difference between IAM User and IAM Role

In professional environments, "machines" like EC2 or Lambda are never given IAM users (fixed keys). Instead, we only configure: "This EC2 is allowed to wear this hat (role)." This is the first step toward secure design.

📚 For those who want to learn "security" from the basics

"I understand the concept of IAM, but I want to see on screen how to actually set up switch roles." "I want to learn how to build a secure network by combining VPC and IAM."

For those people, I recommend this book.

▼ AWS Certified Security - Specialty (SCS-C02) Textbook
https://amzn.to/4b2uFYM

[Practical Edition] Experience this "hat" in your browser
Switching roles is how you can realize this AssumeRole mechanism with a single button in the Management Console.
If you find having too many Chrome tabs difficult, the following article illustrates how to set it up, so please give it a try.

https://zenn.dev/miyaco_log/articles/c9cae820f1effa

3. The Truth about AssumeRole: "Key Exchange" is the Core

Let's get a bit technical here. I mentioned "putting on a hat (AssumeRole)," but what is actually happening within the system?

In reality, a key exchange is taking place in a "security booth" called STS (Security Token Service).

  1. Request: You ask STS, "Please let me wear this hat (role)!"
  2. Review: STS checks the trust relationship (Trust Policy).
  3. Issuance: If everything is okay, "three pieces of information (a temporary key)" are issued.

Receiving this "Temporary Security Credentials" is the true nature of AssumeRole.

▼ [Diagram] The reality of AssumeRole (Interaction with STS)

4. Deciphering the Terrifying JSON (Policies)

"I understand the concept. But writing that JSON is impossible!" I hear you. But that is not a programming language. It is just standard English syntax (SVO).

An IAM policy is always composed of these three elements:

  1. Effect: Allow or Deny
  2. Action: s3:ListBucket (What?)
  3. Resource: arn:aws:s3:::my-bucket (On which target?)

In other words, it is simply writing "Who (Principal)," "What (Resource)," and "What they are allowed to do (Action)."

▼ [Diagram] Structure of a policy

💡 No need to memorize
"Is the S3 write permission 'PutObject' or 'WriteObject'?" There is no need to memorize such things. AWS provides a "Policy Simulator" and a "Visual Editor." What is important is to clarify your intent regarding "who, where, and what to allow."

Once you have mastered IAM through this article, let's tackle "networks" and "databases" with diagrams as well.

5. A Handshake Called "Trust Relationship"

When you create an IAM role (hat), the part where you get stuck most often is the "Trust relationships" tab. This is a rule that specifies, "Who is allowed to wear this hat?"

  • Role for EC2: "Only the EC2 service is allowed to wear this."
  • Admin role for Tanaka-san: "Only Tanaka-san is allowed to wear this."
    If you forget to set this up, you will get an error saying, "You have a hat, but you cannot wear it (cannot transform)."

Conclusion: Permission Management is "Love"

Setting strict IAM rules is not being mean. It is an act of "kindness to your future self (love)" to minimize damage if your access keys ever leak.

  • For humans: Use an IAM User (MFA required)
  • For machines: Use an IAM Role

As long as you follow this principle, IAM is no longer scary. Now, go ahead and master the use of your "hat" with confidence!

📚 For those who want to learn "security" from the basics

"I understand the concept of IAM, but I want to see on screen how to actually set up switch roles." "I want to learn how to build a secure network by combining VPC and IAM."

For those people, I recommend this book. It contains many diagrams and allows you to experience "why this setting is necessary" in a hands-on format.

▼ AWS Certified Security - Specialty (SCS-C02) Textbook
https://amzn.to/4b2uFYM

Next Step: Escape from the "Login Hell" of Browsers

Do you now understand the benefit of not using IAM users?
Next, let's actually change the settings in your browser (Management Console).
Just having "one" password to manage will change your world.

▼ [Diagram] The Magic of Instantly Switching AWS Accounts with "Switch Role"
https://zenn.dev/miyaco_log/articles/c9cae820f1effa

[Update]
The "diagrams" in this article have been praised for being easy to understand!
If you would like to see diagrams for other services, please take a look at the following book, which illustrates major AWS services!
(Currently, a free preview of some parts is available👇)

https://zenn.dev/miyaco_log/books/d26a6fe78b33e9

Discussion