DEV Community

Cover image for ๐Ÿ“˜ AWS IAM Roles Explained Desi-Style โ€” Guest Lecturers, Inter-School Passes & Temporary IDs! (Part 3)

๐Ÿ“˜ AWS IAM Roles Explained Desi-Style โ€” Guest Lecturers, Inter-School Passes & Temporary IDs! (Part 3)

๐ŸŽ’ Welcome back to the IAM School Series โ€“ Part 3!

Weโ€™ve already decoded:

  • ๐Ÿงพ IAM Policies (Hall Passes)
  • ๐Ÿšง Permission Boundaries
  • โ›” Explicit Deny

But what about guests, temporary permissions, and inter-school exchanges?


๐ŸŽญ Part 3: "Guest Lecturers aur Inter-School Guests ka Raaz โ€“ IAM Roles & STS"

Ever wondered:

โ€œYeh sts:AssumeRole kya hai?โ€

โ€œKaise ek Lambda doosre account ka access le leti hai?โ€

Time to simplify this with our school analogy!


๐Ÿซ Meet the Role System โ€” School Guest Management

IAM Concept School Analogy Purpose
IAM Role Guest Lecturer ID Card Temporary identity with specific permissions
sts:AssumeRole Principal Signs the Guest Entry Form Grants temporary permission to act like a role
Temporary Credentials Visitor Badge Valid for Few Hours Short-term access for specific duties

๐Ÿซ School Example: Mr. Sharma, The Guest Lecturer

๐ŸŽ“ A teacher from another school (School A) visits our school (School B) to teach a class in Room 7B (DynamoDB table).

Steps:

  1. ๐Ÿ“ Mr.Sharma fills out a guest entry form

    (sts:AssumeRole request from Account A)

  2. ๐Ÿงพ The Principal of School B signs and approves it

    (Trust Policy in Account B allows Mr. Sharma to assume the role)

  3. ๐Ÿ“‹ Mr. Sharma receives a temporary visitor badge

    (Temporary credentials issued by STS)

  4. ๐Ÿง‘โ€๐Ÿซ Mr. Sharma teaches in Room 7B only

    (Access limited to a specific DynamoDB table)


๐Ÿ’ป Real AWS Example: Cross-Account DynamoDB Access using IAM Role

Letโ€™s assume:

  • Account A (ID: 111111111111) โ€“ where IAM user mr-sharma exists
  • Account B (ID: 222222222222) โ€“ owns the role and the DynamoDB table Room7B

๐Ÿ›‚ Trust Policy in Account B (GuestLecturerRole):

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::111111111111:user/mr-sharma"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

๐Ÿง  This trust policy allows mr-sharma from Account A to assume the GuestLecturerRole in Account B.

โœ… Role Permissions in Account B (GuestLecturerRole):

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["dynamodb:PutItem"],
      "Resource": "arn:aws:dynamodb:<REGION>:222222222222:table/Room7B"
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

๐Ÿง  This role grants write access (e.g., teaching = putting data) to the Room7B DynamoDB table.


๐Ÿ” Assume Role from Account A (CLI Command):

aws sts assume-role \
  --role-arn arn:aws:iam::222222222222:role/GuestLecturerRole \
  --role-session-name SharmaGuestSession
Enter fullscreen mode Exit fullscreen mode

๐Ÿ“ฆ This command returns temporary credentials:

  • AccessKeyId
  • SecretAccessKey
  • SessionToken

โš™๏ธ Use these credentials to perform DynamoDB actions, for example:

aws dynamodb put-item \
  --table-name Room7B \
  --item '{"StudentID": {"S": "1994"}, "Attendance": {"S": "Present"}}' \
  --region <REGION>
Enter fullscreen mode Exit fullscreen mode

โณ Result:

mr-sharma from Account A can temporarily access the Room7B DynamoDB table in Account B using the GuestLecturerRole.

๐Ÿ” This only works because:

  • โœ… The trust policy permits role assumption
  • โœ… The role permissions grant required DynamoDB access
  • โœ… The user assumes the role correctly via STS

๐ŸŽ“ Just like in school โ€” a guest lecturer can teach in a specific classroom, only after the principal signs off and rules are followed!


๐Ÿง  What is STS Exactly?

Security Token Service (STS) = Principalโ€™s signature authority for guest IDs.

  • ๐Ÿชช Issues temporary credentials
  • ๐Ÿ” Used for cross-account, cross-service, or time-limited access
  • โฑ๏ธ Temporary creds = Expire in minutes to hours
  • ๐Ÿ” Highly secure โ€” just like a valid visitor ID!

โœ… Summary โ€” IAM Roles & STS = Guest Access Done Right

IAM Concept School Analogy AWS Use Case
IAM Role Guest Lecturer ID Card Predefined permissions someone can assume
sts:AssumeRole Entry approval by Principal Grants temporary access via trust policy
Temporary Credentials Visitor Badge Time-limited, session-based AWS access

๐Ÿ”œ Coming Up Next: Part 4 โ€” Temporary Workers, Interns, and Lambda Roles!

๐ŸŽฏ In Part 4, weโ€™ll explore:

  • Lambda roles
  • EC2 instance roles
  • Default session timeouts
  • Use cases like: โ€œIntern ko sirf 1 din ke liye access dena hai, kaise karein?โ€

๐Ÿ“š Stay tuned โ€” IAM school ki kahani abhi baaki hai mere dost! ๐Ÿš€


๐Ÿ‘จโ€๐Ÿ’ป About Me

Hi! I'm Utkarsh, a Cloud Specialist & AWS Community Builder who loves turning complex AWS topics into fun chai-time stories โ˜•

๐Ÿ‘‰ Explore more


๐Ÿ—ฃ๏ธ Your Feedback = My Fuel

If this made IAM:

  • Easy to understand ๐Ÿ’ก
  • Fun to learn ๐ŸŽ‰
  • Or gave you a school flashback ๐ŸŽ’

Then share it, comment, or just say hi โ€” it helps me keep the chai warm and the blogs coming! โ˜๏ธ๐Ÿ’ป


Jai Cloud! Jai Code! Jai IAM! ๐Ÿ‡ฎ๐Ÿ‡ณ๐Ÿš€

Top comments (0)