AssumeRole
Important: You cannot call AssumeRole
AssumeRole
For cross-account access, imagine that you own multiple accounts and need to access resources in each account. You could create long-term credentials in each account to access those resources. However, managing all those credentials and remembering which one can access which account can be time consuming. Instead, you can create one set of long-term credentials in one account and then use temporary security credentials to access all the other accounts by assuming roles in those accounts. For more information about roles, see Roles in Using IAM.
For federation, you can, for example, grant single sign-on access to the AWS Management
Console. If you already have an identity and authentication system in your corporate
network, you don't have to recreate user identities in AWS in order to grant
those user identities access to AWS. Instead, after a user has been authenticated,
you call AssumeRole
The temporary security credentials are valid for the duration that you specified when
calling AssumeRole
Optionally, you can pass an IAM access policy to this operation. If you choose not to pass a policy, the temporary security credentials that are returned by the operation have the permissions that are defined in the access policy of the role that is being assumed. If you pass a policy to this operation, the temporary security credentials that are returned by the operation have the permissions that are allowed by both the access policy of the role that is being assumed, and the policy that you pass. This gives you a way to further restrict the permissions for the resulting temporary security credentials. You cannot use the passed policy to grant permissions that are in excess of those allowed by the access policy of the role that is being assumed. For more information, see Permissions for AssumeRole in Using Temporary Security Credentials.
To assume a role, your AWS account must be trusted by the role. The trust relationship
is defined in the role's trust policy when the role is created. You must also
have a policy that allows you to call sts:AssumeRole
Using MFA with AssumeRole
You can optionally include multi-factor authentication (MFA) information when you
call AssumeRole
"Condition": {"Null": {"aws:MultiFactorAuthAge": false}}
For more information, see Configuring MFA-Protected API Access in the Using IAM guide.
To use MFA with AssumeRole
SerialNumber
TokenCode
SerialNumber
TokenCode
C# |
public AssumeRoleResponse AssumeRole( AssumeRoleRequest request )
- request (AssumeRoleRequest)
- Container for the necessary parameters to execute the AssumeRole service method.
Exception | Condition |
---|---|
MalformedPolicyDocumentException |
The request was rejected because the policy document was malformed. The error message
describes the specific error.
|
PackedPolicyTooLargeException |
The request was rejected because the policy document was too large. The error message
describes how big the policy document is, in packed form, as a percentage of
what the API allows.
|