简体   繁体   中英

assume-role-with-web-identity with boto3

Is there an equivalent way to execute the below command using boto3?

$ aws sts assume-role-with-web-identity \
 --role-arn $AWS_ROLE_ARN \
 --role-session-name mh9test \
 --web-identity-token file://$AWS_WEB_IDENTITY_TOKEN_FILE \
 --duration-seconds 1000 > /tmp/irp-cred.txt
$ export AWS_ACCESS_KEY_ID="$(cat /tmp/irp-cred.txt | jq -r ".Credentials.AccessKeyId")"
$ export AWS_SECRET_ACCESS_KEY="$(cat /tmp/irp-cred.txt | jq -r ".Credentials.SecretAccessKey")"
$ export AWS_SESSION_TOKEN="$(cat /tmp/irp-cred.txt | jq -r ".Credentials.SessionToken")"
$ rm /tmp/irp-cred.txt

There is assume_role_with_web_identity with the following syntax:

response = client.assume_role_with_web_identity(
    RoleArn='string',
    RoleSessionName='string',
    WebIdentityToken='string',
    ProviderId='string',
    PolicyArns=[
        {
            'arn': 'string'
        },
    ],
    Policy='string',
    DurationSeconds=123
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM