Course contentsShow
← Security
Lesson 1742 of 3,05235. Cloud Security - IAMFree lesson

Session Tags and Attribute-Based Access Control

Passing session tags during AssumeRole for fine-grained cross-account authorization and ABAC patterns.

Session Tags and Attribute-Based Access Control

What you'll learn: How to pass session tags during AssumeRole to enable fine-grained, attribute-based authorization across AWS accounts.

The Core Idea

When you assume a role (using AWS STS AssumeRole), you can attach session tags—key-value pairs that travel with the temporary credentials throughout their lifetime. These tags enable Attribute-Based Access Control (ABAC), where access decisions depend on attributes (tags) rather than creating separate policies for every user or scenario.

Think of session tags like security badges with custom fields: instead of printing a new badge for every room access combination, you add attributes like "Department=Engineering" or "Project=Alpha" to one badge, and doors check those attributes dynamically.

How It Works

When calling AssumeRole, you include session tags in the request. These tags become part of the session context and can be referenced in IAM policy conditions using aws:PrincipalTag/key-name.

Example scenario: An external contractor assumes a cross-account role. You pass Project=CustomerX as a session tag. Policies in the target account can then restrict access to only S3 buckets tagged with Project=CustomerX:

{
  "Effect": "Allow",
  "Action": "s3:*",
  "Resource": "*",
  "Condition": {
    "StringEquals": {
      "s3:ExistingObjectTag/Project": "${aws:PrincipalTag/Project}"
    }
  }
}

This policy dynamically matches the session's Project tag to resource tags—no need to update policies when new projects or users are added.

ABAC Cross-Account Patterns

Session tags shine in cross-account scenarios: the assuming account controls tag values, while the target account defines tag-based rules. You can enforce that certain tags are passed (sts:RequestTag) or inherited (sts:TransitiveTagKeys), ensuring consistent attribute propagation through role chains.

Key Takeaway:
Session tags enable ABAC by attaching attributes to temporary credentials during AssumeRole, allowing policies to grant access based on dynamic attribute matching rather than static identity lists—ideal for scalable cross-account authorization.