AWS in 1 Min · Episode 26

AWS STS and AssumeRole explained

How roles lend temporary keys. Watch the one-minute video, then read the details.

David Gomez1:17 video · 3 min read

"A role has its own password and keys." It has neither. An IAM role is a set of permissions with no long-term credentials at all. Nobody logs in as a role. Instead, a trusted identity borrows the role for a while, and the service that does the lending is AWS STS, the Security Token Service. Once you see that, cross-account access, service roles and federated sign-in all turn out to be the same mechanism.

What STS does

STS issues temporary security credentials. Its best-known operation is AssumeRole:

  1. A caller (a user, a role, or an AWS service) calls AssumeRole with the ARN of the role it wants (what an ARN is) and a session name.
  2. STS checks that the caller is allowed.
  3. STS returns an access key ID, a secret access key and a session token, with an expiry time.

The caller then signs requests with those three values and acts with the role's permissions until they expire. Related operations cover other entry points, such as AssumeRoleWithSAML and AssumeRoleWithWebIdentity for federated identities.

Two policies decide

Every role has two policies, and people often mix them up:

  • The trust policy says who may assume the role: an account, a specific user or role, or an AWS service.
  • The permissions policy says what the session can do once the role is assumed.

Inside one account, the caller either needs an identity policy that allows sts:AssumeRole on that role, or must be named directly in the role's trust policy. Across accounts, both sides are required: the role must trust the other account, and the caller's own account must allow the call.

A common mistake is writing a generous permissions policy and a careless trust policy. The trust policy is the front door; keep the list of principals short.

How long a session lasts

  • The default is one hour.
  • The minimum is 15 minutes.
  • The maximum is whatever the role's maximum session duration allows, which an administrator can set between 1 and 12 hours.
  • With role chaining (using one role's credentials to assume another), the session is limited to one hour.

Shorter is safer. Pick the shortest duration that lets the job finish.

Cross-account access without shared passwords

This is the standard way to work across accounts. A role in account B trusts account A; people or systems in A assume it and get temporary credentials for B. Nobody creates a duplicate user and nobody shares a password or an access key.

Two extras worth knowing:

  • When you let a third party assume a role in your account, require an external ID in the trust policy, so their other customers can't trick them into using your role.
  • A trust policy can require MFA with the aws:MultiFactorAuthPresent condition.

Every AssumeRole call is recorded in CloudTrail with the session name, so you can see who borrowed what.

Where AI fits

AI agents get their permissions the same way. When you create an agent in Amazon Bedrock, you give it a service role whose trust policy names the Bedrock service. Bedrock assumes that role, and the agent calls models, knowledge bases and your Lambda functions with short-lived credentials. There is no access key to store in the agent's configuration.

For agents you run yourself, STS offers a useful control: a session policy passed to AssumeRole. The session's permissions become the intersection of the role's policy and the session policy, so an orchestrator can hand each task a narrower slice of the role, for a short time. A session policy can only reduce permissions, never add to them.

Quick recap

  • Roles have no passwords or keys; they are borrowed.
  • STS lends temporary credentials through AssumeRole, one hour by default.
  • The trust policy decides who can borrow; the permissions policy decides what they can do.
AWS in 1 Min #26 · 1:17

Need an AWS expert on your team?

I'm David, an AWS expert and fractional cloud consultant. I work alongside your team to run your cloud and infrastructure: architecture, security, cost and day-to-day operations. You get senior AWS experience when you need it, without the cost of a full-time hire.

  • Architecture reviews and a clear plan for what to fix first
  • Security hardening: IAM, networking, audits
  • Lower AWS bills without slowing your team down
  • Hands-on help with AI workloads on AWS