Skip to main content

🛡️ AWS Security Token Service (STS)

AWS Security Token Service (STS) enables you to create temporary, limited-privilege credentials to access AWS resources.

These credentials are short-lived and are used instead of long-term access keys for enhanced security.

Temporary credentials include:

  • Access Key ID
  • Secret Access Key
  • Session Token

🧭 How It Works

  1. A user or service requests temporary credentials (e.g., using AssumeRole).
  2. STS validates the request and issues temporary credentials.
  3. These credentials are used to access AWS resources.
  4. Once expired, new credentials must be generated.

🧰 Common Use Cases

Use CaseDescription
IAM Role AssumptionAllows a user, service, or application to assume a role and gain temporary access (same or cross-account).
Identity FederationEnables external identities (e.g., from Active Directory, Google, or SAML providers) to access AWS resources.
EC2 Instance RolesAutomatically provides temporary credentials to EC2 instances through STS, refreshed in the background.
FeatureDescription
Temporary DurationCredentials are valid for a limited time (from minutes to hours).
Automatic RotationFor EC2, Lambda, and other services, STS handles credential refresh automatically.
Fine-Grained AccessTemporary credentials inherit permissions from the IAM role assumed.
Cross-Account AccessSimplifies granting access between AWS accounts.

🧩 Important STS API Calls

API CallDescription
AssumeRoleGrants temporary credentials to assume a specified IAM role.
GetSessionTokenProvides temporary credentials for an IAM user.
AssumeRoleWithSAMLUsed with SAML 2.0 for identity federation.
AssumeRoleWithWebIdentityUsed with web identity providers like Google, Facebook, or Amazon Cognito.

🧠 Example Scenario

A user in Account A needs access to an S3 bucket in Account B:

  1. The user calls STS AssumeRole for a role defined in Account B.
  2. STS returns temporary credentials.
  3. The user uses these credentials to access the S3 bucket within the allowed time window.

🧩 Exam Tip

Any question mentioning temporary, limited-privilege credentials or cross-account access points to AWS STS.

✅ Summary Table

ConceptDescription
Service NameAWS Security Token Service (STS)
PurposeGenerate temporary credentials for secure access
Credential ComponentsAccess Key ID, Secret Access Key, Session Token
Used WithIAM roles, Federation, EC2 Instance Roles
Security BenefitNo need to use or store long-term credentials