๐ 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:
๐ Mr.Sharma fills out a guest entry form
(sts:AssumeRole
request from Account A)๐งพ The Principal of School B signs and approves it
(Trust Policy in Account B allows Mr. Sharma to assume the role)๐ Mr. Sharma receives a temporary visitor badge
(Temporary credentials issued by STS)๐งโ๐ซ 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 usermr-sharma
exists -
Account B (ID:
222222222222
) โ owns the role and the DynamoDB tableRoom7B
๐ 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"
}
]
}
๐ง 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"
}
]
}
๐ง 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
๐ฆ 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>
โณ 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)