【发布时间】:2022-12-02 05:39:47
【问题描述】:
I assumed a role using this piece of code
import boto3
session = boto3.Session(profile_name="learnaws-test")
sts = session.client("sts")
response = sts.assume_role(
RoleArn="arn:aws:iam::xxx:role/s3-readonly-access",
RoleSessionName="learnaws-test-session"
)
new_session = Session(aws_access_key_id=response['Credentials']['AccessKeyId'],
aws_secret_access_key=response['Credentials']['SecretAccessKey'],
aws_session_token=response['Credentials']['SessionToken'])
and now I'm ending up with new_session, at this point is the role assumed? and how can I check that it is assumed? Also, now I want to assume another role from a different account. how do I utilized the new_session to do that, is that even possible? basically, my work is intended like this -> sso login -> assume a role in account A -> assume a role in account B. I can't directly assume the role in account B. If anyone can provide a layout on how to achieve it, that would be great.
Hopefully my question is clear.
【问题讨论】:
标签: amazon-web-services boto3 amazon-iam assume-role