How does `sts:AssumeRole` work, step by step?
IntermediateConceptIAM Advanced, STS and Multi-Account
Answer
- Caller invokes
AssumeRolewith the target role ARN and a session name. - STS checks the role's trust policy allows the caller and, cross-account, that the caller's own policy allows
sts:AssumeRole. - STS returns
AccessKeyId,SecretAccessKeyandSessionToken, valid 15 minutes to the role's max session duration (default 1 hour, up to 12). - The caller signs requests with these; CloudTrail logs them with the assumed-role ARN and the session name for attribution.
aws sts assume-role --role-arn arn:aws:iam::222222222222:role/deploy \
--role-session-name ci-$BUILD_ID --duration-seconds 3600
More on IAM Advanced, STS and Multi-Account
Explain the IAM policy evaluation logic.AdvancedHow does cross-account access evaluation differ from same-account?AdvancedWhat is the difference between AssumeRole, AssumeRoleWithWebIdentity and AssumeRoleWithSAML?IntermediateWhat is a permission boundary and when would you use one?IntermediateWhat do Service Control Policies do and not do?IntermediateDeny-list vs allow-list SCP strategy: which do you pick?Advanced