GetRole - Amazon Identity and Access Management
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).


Retrieves information about the specified role, including the role's path, GUID, ARN, and the role's trust policy that grants permission to assume the role. For more information about roles, see IAM roles in the IAM User Guide.


Policies returned by this operation are URL-encoded compliant with RFC 3986. You can use a URL decoding method to convert the policy back to plain JSON text. For example, if you use Java, you can use the decode method of the utility class in the Java SDK. Other languages and SDKs provide similar functionality.

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.


The name of the IAM role to get information about.

This parameter allows (through its regex pattern) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-

Type: String

Length Constraints: Minimum length of 1. Maximum length of 64.

Pattern: [\w+=,.@-]+

Required: Yes

Response Elements

The following element is returned by the service.


A structure containing details about the IAM role.

Type: Role object


For information about the errors that are common to all actions, see Common Errors.


The request was rejected because it referenced a resource entity that does not exist. The error message describes the resource.

HTTP Status Code: 404


The request processing has failed because of an unknown error, exception or failure.

HTTP Status Code: 500



This example illustrates one usage of GetRole.

Sample Request &RoleName=S3Access &Version=2010-05-08 &AUTHPARAMS

Sample Response

<GetRoleResponse xmlns=""> <GetRoleResult> <Role> <Path>/application_abc/component_xyz/</Path> <Arn>arn:aws:iam::123456789012:role/application_abc/component_xyz/S3Access</Arn> <RoleName>S3Access</RoleName> <AssumeRolePolicyDocument> {"Version":"2012-10-17","Statement":[{"Effect":"Allow", "Principal":{"Service":[""]},"Action":["sts:AssumeRole"]}]} </AssumeRolePolicyDocument> <CreateDate>2012-05-08T23:34:01Z</CreateDate> <RoleId>AROADBQP57FF2AEXAMPLE</RoleId> <RoleLastUsed> <LastUsedDate>2019-11-20T17:09:20Z</LastUsedDate> <Region>us-east-1</Region> </RoleLastUsed> </Role> </GetRoleResult> <ResponseMetadata> <RequestId>df37e965-9967-11e1-a4c3-270EXAMPLE04</RequestId> </ResponseMetadata> </GetRoleResponse>

See Also

For more information about using this API in one of the language-specific Amazon SDKs, see the following: