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

AWS STS and AssumeRole Mechanics

How Security Token Service generates temporary credentials and the AssumeRole API workflow with session tokens.

AWS STS and AssumeRole Mechanics

What You'll Learn

You'll understand how AWS Security Token Service (STS) generates temporary credentials and the precise workflow when a principal assumes a role.

How STS Works

AWS Security Token Service (STS) is the engine that creates temporary security credentials on demand. Think of it as a secure ticket booth: instead of giving you permanent keys to the building, it issues time-limited passes that expire automatically.

When you call the AssumeRole API, here's what happens:

The AssumeRole Workflow

  1. Request: A principal (user, service, or federated identity) calls AssumeRole targeting a specific IAM role ARN
  2. Trust Evaluation: STS checks the role's trust policy to verify the caller is allowed to assume it
  3. Credential Generation: If authorized, STS creates three components:
    • Access Key ID (identifies the session)
    • Secret Access Key (authenticates requests)
    • Session Token (proves the credentials are temporary and valid)
  4. Response: STS returns these credentials with an expiration timestamp (default 1 hour, configurable up to 12 hours)
  5. Usage: The caller includes all three values in subsequent AWS API calls

Session Tokens: The Critical Difference

The session token is what distinguishes temporary credentials from permanent ones. Every API request must include it alongside the access key pair. AWS validates this token with each call, checking it hasn't expired or been revoked.

This mechanism enables secure delegation without sharing long-term credentials—a service can assume a role, get temporary access, and those credentials automatically become worthless after expiration.

Key Takeaway: AWS STS generates time-bound credentials through AssumeRole by validating trust policies and issuing a trio of values (access key, secret key, and session token) that automatically expire, eliminating the risk of permanent credential exposure.