How STS Issues Temporary Credentials
Understand the security token service behind every role.
How STS Issues Temporary Credentials is a free AWS Security Academy lesson on CoddyKit — lesson 1 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.
The Token Service
The Security Token Service (STS) is the AWS service that issues temporary security credentials. Every time a role is assumed or an identity is federated, STS hands out short-lived credentials instead of permanent keys. Understanding STS is central to the exam because temporary credentials underpin nearly all secure access patterns on AWS.
What Temporary Credentials Are
STS credentials consist of three parts: an access key ID, a secret access key, and a session token. The session token is what distinguishes them from long-term keys; it must accompany every signed request. All three expire together after a defined lifetime, making the credentials self-limiting.
Why Temporary Is Safer
Because they expire automatically (from 15 minutes to 12 hours), temporary credentials sharply limit the damage from a leak. There are no keys to rotate manually and nothing permanent to steal. This is why AWS recommends temporary credentials over long-term access keys almost everywhere, a point the exam reinforces repeatedly.
The Core STS APIs
STS exposes a handful of operations:
- AssumeRole — assume a role in the same or another account.
- AssumeRoleWithSAML — federate via a SAML identity provider.
- AssumeRoleWithWebIdentity — federate via OIDC/web identity.
- GetSessionToken / GetFederationToken — for MFA and IAM-user federation.
AssumeRole Flow
The most common call is AssumeRole. The caller, already authenticated, requests a role; STS verifies the role's trust policy permits the caller, then returns temporary credentials carrying the role's permissions. The caller uses them until they expire, then assumes the role again to refresh.
Calling AssumeRole
This CLI call assumes a role and returns temporary credentials. The role ARN and a session name are required; the session name appears in CloudTrail for auditing.
aws sts assume-role \
--role-arn arn:aws:iam::123456789012:role/Audit \
--role-session-name security-reviewRegional and Global Endpoints
STS historically used a single global endpoint, but AWS now offers regional STS endpoints. Using the regional endpoint reduces latency and improves resilience, and some compliance setups require it. Newer regions are not reachable through the global endpoint, so enabling regional STS is a recommended configuration.
Caller Identity
The GetCallerIdentity operation returns the account, user ID, and ARN of whoever is making the call. It needs no special permissions and is the go-to way to confirm which identity your credentials currently represent, useful when debugging assumed-role sessions during an investigation.
aws sts get-caller-identityCredentials in CloudTrail
Every STS call is logged in CloudTrail, including who assumed which role and the session name they chose. This trail lets investigators trace exactly which human or service obtained temporary credentials and what they then did. Meaningful session names make this audit far more useful.
Session Token in Practice
Applications using temporary credentials must send the session token with each request; the AWS SDK and CLI do this automatically once configured. If you ever see authentication failures with temporary credentials, a missing or mismatched session token is a frequent cause to check.
Putting STS to Work
STS is the engine behind roles and federation: it issues short-lived access key, secret, and session token sets that expire on their own, vastly safer than permanent keys. Use AssumeRole family operations, prefer regional endpoints, give sessions meaningful names for CloudTrail, and let temporary credentials replace long-term ones wherever you can.
Quick Check
Test your STS basics.
Recap
The Security Token Service (STS) issues temporary credentials: an access key, secret, and session token that expire after 15 minutes to 12 hours. Core APIs include AssumeRole, AssumeRoleWithSAML, and AssumeRoleWithWebIdentity. Prefer regional endpoints, use meaningful session names for CloudTrail, and replace long-term keys with temporary ones.
Frequently asked questions
Is the “How STS Issues Temporary Credentials” lesson free?
Yes — the full text of “How STS Issues Temporary Credentials” 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 “How STS Issues Temporary Credentials”?
Understand the security token service behind every role. 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 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “How STS Issues Temporary Credentials” 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