Session Policies and Tag-Based Scoping
Shrink permissions further at the moment a role is assumed.
Session Policies and Tag-Based Scoping is a free AWS Security Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AWS Security Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Narrowing at Assume Time
Sometimes you want to grant a role but restrict what a particular session can do without editing the role itself. Session policies and session tags let you shrink permissions at the exact moment a role is assumed. These advanced STS features support fine-grained, scalable least privilege that the exam rewards.
What a Session Policy Is
A session policy is an inline or managed policy passed to AssumeRole (via Policy or PolicyArns). It does not grant new permissions; it can only filter the role's existing permissions for that session. The effective permissions are the intersection of the role's policies and the session policy.
Intersection Logic
Because the result is an intersection, a session policy can never let a session do more than the role already allows. If the role grants s3:* but the session policy allows only s3:GetObject, the session can only get objects. This makes session policies a safe way to hand out a downscoped slice of a broader role.
A Use Case
A common use: a single powerful role is assumed by an orchestration tool that, for each job, attaches a session policy limiting that job to one bucket or one resource group. Each session is tightly scoped even though the underlying role is broad. This avoids creating dozens of narrowly tailored roles.
Passing a Session Policy
This CLI snippet shows passing an inline session policy that restricts the session further. The role must already permit these actions for them to take effect.
aws sts assume-role \
--role-arn arn:aws:iam::123456789012:role/Broad \
--role-session-name job-42 \
--policy file://restrict.jsonIntroducing Session Tags
Session tags are key-value attributes attached to a session at AssumeRole time. Passed via the Tags parameter, they become part of the request context and can be read in policies through aws:PrincipalTag. Session tags carry attributes about who is assuming the role into every authorization decision.
Tags Power ABAC
Session tags are the backbone of Attribute-Based Access Control (ABAC) for assumed roles. A policy can require that the session's aws:PrincipalTag/Project equals the resource's aws:ResourceTag/Project, granting access only when the project tags match. One policy then serves many projects, scaling cleanly.
Transitive Tags
When roles are chained, ordinary session tags do not carry forward. Marking a tag as transitive makes it persist through subsequent role assumptions in the chain. This ensures attributes like the original user's department follow the identity across multiple hops, important for consistent ABAC.
Permissions to Tag
Passing session tags requires the sts:TagSession permission in addition to sts:AssumeRole. The trust policy can also restrict which tag keys or values are allowed. Controlling who may set which session tags prevents users from granting themselves access by self-assigning privileged tag values.
Combining Both Tools
Session policies and session tags work together: tags express who the session represents for ABAC matching, while session policies cap what the session may do. Together they let one broad role safely serve many tightly scoped sessions, the kind of elegant, scalable design the exam highlights.
Putting It Together
Use session policies to intersect and shrink a role's permissions per session, never to add. Use session tags (with sts:TagSession) to drive ABAC via aws:PrincipalTag, marking tags transitive when chaining. These STS features deliver per-session least privilege from a small number of reusable roles.
Quick Check
Test session scoping.
Recap
Session policies passed to AssumeRole intersect with the role's permissions, shrinking but never expanding them. Session tags (needing sts:TagSession) feed ABAC through aws:PrincipalTag, and transitive tags persist across role chaining. Together they enable per-session least privilege from a few reusable roles.
Frequently asked questions
Is the “Session Policies and Tag-Based Scoping” lesson free?
Yes — the full text of “Session Policies and Tag-Based Scoping” is free to read here on the web, and the AWS Security Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AWS Security Academy course, upgrade to CoddyKit PRO.
What will I learn in “Session Policies and Tag-Based Scoping”?
Shrink permissions further at the moment a role is assumed. You practise AWS Security Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start AWS Security Academy?
No prior experience is required. AWS Security Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Session Policies and Tag-Based Scoping” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this AWS Security Academy lesson?
Yes. Every AWS Security Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- How STS Issues Temporary Credentials
- AssumeRole and the Session Lifetime
- External ID and the Confused Deputy
- Session Policies and Tag-Based Scoping