Jump to Content

This API Documentation is now deprecated

We are excited to announce our new API Documentation.

Class GetRoleCommandProtected

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 java.net.URLDecoder utility class in the Java SDK. Other languages and SDKs provide similar functionality.

Example

Use a bare-bones client and the command you need to make an API call.

import { IAMClient, GetRoleCommand } from "@aws-sdk/client-iam"; // ES Modules import
// const { IAMClient, GetRoleCommand } = require("@aws-sdk/client-iam"); // CommonJS import
const client = new IAMClient(config);
const input = { // GetRoleRequest
RoleName: "STRING_VALUE", // required
};
const command = new GetRoleCommand(input);
const response = await client.send(command);
// { // GetRoleResponse
// Role: { // Role
// Path: "STRING_VALUE", // required
// RoleName: "STRING_VALUE", // required
// RoleId: "STRING_VALUE", // required
// Arn: "STRING_VALUE", // required
// CreateDate: new Date("TIMESTAMP"), // required
// AssumeRolePolicyDocument: "STRING_VALUE",
// Description: "STRING_VALUE",
// MaxSessionDuration: Number("int"),
// PermissionsBoundary: { // AttachedPermissionsBoundary
// PermissionsBoundaryType: "PermissionsBoundaryPolicy",
// PermissionsBoundaryArn: "STRING_VALUE",
// },
// Tags: [ // tagListType
// { // Tag
// Key: "STRING_VALUE", // required
// Value: "STRING_VALUE", // required
// },
// ],
// RoleLastUsed: { // RoleLastUsed
// LastUsedDate: new Date("TIMESTAMP"),
// Region: "STRING_VALUE",
// },
// },
// };

Param

GetRoleCommandInput

Returns

GetRoleCommandOutput

See

Throws

NoSuchEntityException (client fault)

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

Throws

ServiceFailureException (server fault)

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

Throws

IAMServiceException

Base exception class for all service exceptions from IAM service.

Example

To get information about an IAM role

// The following command gets information about the role named Test-Role.
const input = {
"RoleName": "Test-Role"
};
const command = new GetRoleCommand(input);
const response = await client.send(command);
/* response ==
{
"Role": {
"Arn": "arn:aws:iam::123456789012:role/Test-Role",
"AssumeRolePolicyDocument": "<URL-encoded-JSON>",
"CreateDate": "2013-04-18T05:01:58Z",
"MaxSessionDuration": 3600,
"Path": "/",
"RoleId": "AROADBQP57FF2AEXAMPLE",
"RoleLastUsed": {
"LastUsedDate": "2019-11-18T05:01:58Z",
"Region": "us-east-1"
},
"RoleName": "Test-Role"
}
}
*/
// example id: 5b7d03a6-340c-472d-aa77-56425950d8b0

Hierarchy

Constructors

Properties

Methods

Constructors

Properties

Methods