Prefer video? The full walkthrough is at the top of this post, and the most common cases have one-minute Shorts right where they come up. This guide first went out on the AWS Cloud in a Minute newsletter.

The one-minute answer

The problem: your app, script or pipeline calls sts:AssumeRole, and AWS answers AccessDenied. The role exists, the ARN looks right, and someone says it worked last week.

How AWS decides: assuming a role takes two yeses. The role’s trust policy has to name you as a principal it trusts, and your own permissions have to allow sts:AssumeRole on that role. On top of that, any condition in the trust policy has to be met, and nothing in your organization can deny it.

Where to look first: read the full error message. It says either no role trust policy allows or names another policy type, such as identity-based or service control policy. That tells you which side to fix, the role’s account or yours.

The rest of this guide explains how AssumeRole is evaluated, goes through the causes in the order worth checking, and ends with a checklist.

How AssumeRole decides

Every role has two policies, and they answer different questions:

  • The trust policy (on the role) says who may assume the role. Its Principal can be an account, a user, a role or an AWS service.
  • The permissions policies (on the role) say what the role can do once you have it. They play no part in whether you can assume it.

Your side has its own say. Whether you need sts:AssumeRole in your identity-based policy depends on where the role lives:

  • Same account, trust policy names your user or role ARN: the trust policy alone is enough, unless a permissions boundary or session policy on your role leaves it out.
  • Same account, trust policy names the account (arn:aws:iam::111122223333:root): that delegates the decision to your account’s identity-based policies, so yours must also allow sts:AssumeRole on the role.
  • Another account: always both. Their trust policy must name you or your account, and your identity policy must allow sts:AssumeRole on their role ARN.

Three more things can stop the call even when both say yes:

  • Conditions in the trust policy, such as an external ID, MFA, a source IP range or your organization ID, must all be met.
  • Guardrails never grant anything but can deny: a service control policy (SCP) on your account, a resource control policy (RCP) on the role’s account, or a permissions boundary on your role. RCPs cover AWS STS, but not resources in the management account. Neither SCPs nor RCPs restrict service-linked roles. If the call goes through an STS VPC endpoint, its endpoint policy can deny it too.
  • Session limits: DurationSeconds can’t exceed the role’s maximum session duration, which is 1 to 12 hours, and a role assumed from another role is limited to one hour. Asking for more fails with a ValidationError, not AccessDenied.

Read the error first

An AssumeRole denial usually looks like this, and the end of it is the clue:

User: arn:aws:iam::111122223333:user/John is not authorized to perform: sts:AssumeRole because no role trust policy allows the sts:AssumeRole action 

The first part tells you who AWS thinks you are. If that ARN isn’t the user or role you expected, stop there: the request is running with different credentials.

The last part tells you which policy said no:

  • no role trust policy allows or with an explicit deny in the role trust policy: the problem is on the role’s side. Check the trust policy’s principal and conditions.
  • no identity-based policy allows: your own policy doesn’t allow sts:AssumeRole on that role.
  • no permissions boundary allows, no session policy allows, or a service control or resource control policy: a guardrail is blocking it. For an explicit deny in a managed policy, an SCP or an RCP, the message can include that policy’s ARN when the call stays inside your account or organization. A deny in the trust policy or in an inline policy shows no ARN. If several policies deny the call, the message names only one, so fixing it can reveal the next.

In the caller’s account, CloudTrail records the failed call as an AssumeRole event with an AccessDenied error code.

The causes, one by one

Check them in this order. The first five are on the role’s side, in its trust policy. The last two are on your side.

The trust policy says no

1. The trust policy doesn’t name you. The principal is a different account, a different role, or the ARN has a typo. Role names in ARNs are case sensitive, so App-Role and app-role are different roles. Often the caller is simply not who you think: a different CLI profile, or the default credentials of the machine.

Fix: compare the ARN at the start of the error with the trust policy’s Principal, then add your role ARN or your account.

2. The role was deleted and recreated. When you save a trust policy that names a specific role or user, AWS stores that principal’s unique ID. Recreate the role with the same name and it gets a new ID, so the old trust policy no longer matches. The policy then shows a long ID where the ARN used to be.

Fix: edit the trust policy, put the ARN back, and save it again.

3. A condition in the trust policy isn’t met. The most common ones:

  • sts:ExternalId: the caller has to pass the matching external ID, which third-party tools often require.
  • aws:MultiFactorAuthPresent: the caller has to sign in with MFA, or pass the MFA device and code on the call.
  • A source IP range, aws:PrincipalOrgID, or a date that has passed.

Fix: read the trust policy’s Condition block line by line and pass what it expects, such as --external-id or --serial-number with --token-code.

4. You pass session tags or a source identity. If the call passes --tags or --transitive-tag-keys, or a service such as EKS Pod Identity tags the session, the trust policy also has to allow sts:TagSession. Setting a source identity needs sts:SetSourceIdentity, both in the trust policy and in the caller’s own policy. Once set, a source identity carries into chained sessions, so the next role needs it too. Without these, the call fails even though sts:AssumeRole is allowed.

Fix: add the extra action to the trust policy statement for that principal.

5. An AWS service can’t assume it. A role for a service has to trust that service: lambda.amazonaws.com for Lambda, ec2.amazonaws.com for EC2, ecs-tasks.amazonaws.com for ECS task roles. A role copied from a cross-account setup only trusts accounts, so the service is refused. You see that as an error from the service, not as an AccessDenied returned to you, and a condition such as aws:SourceAccount can block it too. Attaching the role to the service is a separate check, which needs iam:PassRole, not sts:AssumeRole.

Fix: add the service principal to the trust policy.

Your side says no

6. Your policy doesn’t allow sts:AssumeRole. From another account you always need it, and in the same account you need it when the trust policy names the account rather than you. The Resource has to cover the role’s ARN.

Fix: allow sts:AssumeRole on the exact role ARN. Avoid *, which lets you assume any role that trusts your account.

7. A guardrail denies it. A service control policy on your account, a resource control policy on the role’s account, a permissions boundary or session policy on your role, or an STS VPC endpoint policy if the call goes through one. None of them grant anything, and the error names the type.

Fix: you usually can’t change SCPs and RCPs yourself. Send the policy type and ARN from the error to whoever runs your organization.

Related errors that aren’t AccessDenied

  • ValidationError on DurationSeconds: you asked for a session longer than the role’s maximum session duration, which runs from 1 to 12 hours and defaults to 1 hour. When you assume a role from another role, called role chaining, the cap is one hour whatever the setting says. Ask for a shorter session, or raise the role’s maximum if the call isn’t chained.
  • RegionDisabled: the caller used an STS Regional endpoint in a Region where STS isn’t active for the account. Activate the Region, or use another endpoint.

The role chaining limit catches a lot of people, so here it is in under a minute:

How to check it

Run these from the same place as the failing call, with the same credentials.

1. Confirm who you are. Compare this ARN with the trust policy’s principal:

aws sts get-caller-identity 

2. Read the role’s trust policy and session limit. Run this in the role’s account:

aws iam get-role --role-name app-role \ --query '{trust: Role.AssumeRolePolicyDocument, maxSeconds: Role.MaxSessionDuration}' 

Look at the Principal, every Condition, and whether a long ID sits where an ARN should be.

3. Reproduce the call by hand. Add exactly what the trust policy expects, and nothing else:

aws sts assume-role \ --role-arn arn:aws:iam::444455556666:role/app-role \ --role-session-name test \ --external-id your-external-id 

If this works and your app doesn’t, the app is using other credentials or other parameters.

4. Test your side. The IAM policy simulator shows whether your identity-based policies allow sts:AssumeRole on that role ARN, and which statement decides it. It includes SCPs but not RCPs, it doesn’t fetch the role’s trust policy for you, and AWS warns results can differ for role chaining. Use it for causes 6 and 7.

5. Find the failed call in CloudTrail. Event history keeps management events for 90 days. Search the caller’s account, in the Region of the STS endpoint it used (the global endpoint logs to us-east-1), and filter on the event name:

aws cloudtrail lookup-events \ --lookup-attributes AttributeKey=EventName,AttributeValue=AssumeRole \ --max-results 20 

The failed calls carry AccessDenied as the error code, and the error message usually carries the same denial text. A denied cross-account call isn’t logged in the role’s account at all.

Checklist

  1. aws sts get-caller-identity shows the user or role you expect.
  2. The full error says which policy type denied the call.
  3. The trust policy’s Principal names your role ARN or your account, spelled exactly, with the same case.
  4. The trust policy shows ARNs, not long IDs left behind by a deleted role.
  5. Every Condition in the trust policy is met: external ID, MFA, source IP, organization.
  6. If you pass session tags or a source identity, the trust policy allows sts:TagSession or sts:SetSourceIdentity.
  7. Roles for Lambda, EC2 or ECS trust the right service principal.
  8. Your identity policy allows sts:AssumeRole on the exact role ARN, when you need it.
  9. No SCP, RCP, permissions boundary or session policy denies it.
  10. DurationSeconds is within the role’s maximum, and one hour or less when you chain roles.

From the field

Multi-account setups live on AssumeRole: pipelines deploying into workload accounts, collectors in one account writing to central buckets in another. The AccessDenied calls that took longest were rarely a missing sts:AssumeRole. They were a role someone had deleted and recreated, so the trust policy held a dead ID, or a trust policy condition, such as an external ID, that the caller didn’t send exactly as written. So the first thing I run now is aws sts get-caller-identity, and the second is aws iam get-role in the other account to read the trust policy. Those two usually show which side to fix.

Keep going

Related guides:

Shorts from this guide: AccessDenied after recreating a role, AssumeRole fails for a 2-hour session.

Get the next one: new guides go out first on the AWS Cloud in a Minute newsletter, with a long video and Shorts on YouTube. I also run Azure Cloud in a Minute and Kubernetes in a Minute.

Sources

All from AWS:

Independent writer, not affiliated with or endorsed by Amazon Web Services.