Assume Role as an IAM User¶
When assuming an IAM role, you get a set of temporary credentials you can use to access resources as defined by the attached IAM policies.
Prerequisites¶
An IAM user
UserTestinAccountExample.An IAM role in
AccountExample2with a trust policy enablingUserTestto assume the role.
Procedure¶
Run the following command to assume the role and get temporary credentials.
aws --endpoint-url https://sts.<base-domain-name> sts assume-role --role-arn arn:aws:iam::123456789012:role/ExampleRole1 --role-session-name session-example
<ROLE_ARN> is an IAM role ARN you created, or one of the default
ARTESCA roles:
arn:aws:iam::123456789:role/scality-internal/storage-manager-rolearn:aws:iam::123456789:role/scality-internal/storage-account-owner-rolearn:aws:iam::123456789:role/scality-internal/data-consumer-role
Output example:
{
"AssumedRoleUser": {
"AssumedRoleId": "AROA3XFRBF535PLBIFPI4:session-example",
"Arn": "arn:aws:sts::123456789012:assumed-role/ExampleRole1/session-example"
},
"Credentials": {
"SecretAccessKey": "9drTJvcXLB89EXAMPLELB8923FB892xMFI",
"SessionToken": "AQoXdzELDDY////EXAMPLE/////Kcgo5OytwU=",
"Expiration": "2016-03-15T00:05:07Z",
"AccessKeyId": "ASIAJEXAMPLEXEG2JICEA"
}
}
Note
Refer to Use AWS CLI with Temporary Credentials to start using those temporary credentials.
The assume-role API enables the IAM user to assume roles in the current account or in other accounts.

