list-attached-role-policies¶
Lists all managed policies that are attached to the specified IAM role.
An IAM role can also have inline policies embedded with it. To list the inline policies for a role, use list-role-policies. Refer to Managed policies and inline policies for more information.
Paginate the results using the MaxItems and Marker parameters.
Use the PathPrefix parameter to limit the list of policies to only
those matching the specified path prefix. If there are no policies attached
to the specified role (or none that matches the specified path prefix),
the operation returns an empty list.
Refer to AWS API Documentation and aws help for more information on global parameters.
list-attached-role-policies is a paginated operation. Multiple API calls can be
issued to retrieve the entire data set of results. Disable pagination by providing
the --no-paginate argument. When using --output text and the --query argument
on a paginated response, the --query argument must extract data from the results
of the query expression AttachedPolicies.
Synopsis¶
list-attached-role-policies
--role-name <value>
[--path-prefix <value>]
[--max-items <value>]
[--starting-token <value>]
[--page-size <value>]
Options¶
--role-name (string)
The name of the role to list attached policies for. 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 the
characters: _+=,.@-.
--path-prefix (string)
This parameter allows (through its regex pattern) a string of characters
consisting of either a forward slash / by itself or a string that
must begin and end with forward slashes. In can also contain any
ASCII character from the exclamation mark \u0021, through the DEL character
\u007F, including most punctuation characters, digits, and upper and
lowercase letters.
--max-items (integer)
The total number of items to return in the command’s output. If the total number
of items available is more than the value specified, a NextToken is provided in
the command’s output. To resume pagination, provide the NextToken value in the
starting-token argument of a subsequent command.
Do not use the NextToken response element directly outside of the AWS CLI.
For usage examples, refer to the Pagination documentation.
--starting-token (string)
A token to specify where to start paginating. This is the NextToken from a
previously truncated response.
For usage examples, refer to the Pagination documentation.
--page-size (integer)
The size of each page to get in the AWS service call. This does not affect the number of items returned in the command’s output. Setting a smaller page size results in more calls to the AWS service, retrieving fewer items in each call. This can help prevent the AWS service calls from timing out.
For usage examples, refer to the Pagination documentation.
Examples¶
To list all managed policies that are attached to the specified role
This command returns the names and ARNs of the managed policies attached to
the IAM role named SecurityAuditRole in the AWS account.
aws iam list-attached-role-policies --role-name SecurityAuditRole
Output example:
{
"AttachedPolicies": [
{
"PolicyName": "SecurityAudit",
"PolicyArn": "arn:aws:iam::aws:policy/SecurityAudit"
}
],
"IsTruncated": false
}
Refer to Overview of IAM Policies for more information.
Output¶
AttachedPolicies -> (list)
A list of the attached policies.
(structure)
Contains information about an attached policy.
An attached policy is a managed policy that has been attached to a user, group, or role. This data type is used as a response element in the ListAttachedGroupPolicies, ListAttachedRolePolicies, ListAttachedUserPolicies, and GetAccountAuthorizationDetails operations.
Refer to Managed policies and inline policies for more information.
PolicyName -> (string)
The name of the attached policy.
PolicyArn -> (string)
The Amazon Resource Name (ARN). ARNs are unique identifiers for Amazon Web Services resources.
Refer to Amazon Resource Names (ARNs) for more information.
IsTruncated -> (boolean)
A flag that indicates if there are more items to return. If your results were truncated, you can make a subsequent pagination request using the
Markerrequest parameter to retrieve more items.Note
IAM can return fewer than the
MaxItemsnumber of results even when there are more results available. It is recommended that you checkIsTruncatedafter each call to ensure that you receive all your results.
Marker -> (string)
When
IsTruncatedis true, this element is present and contains the value to use for theMarkerparameter in a subsequent pagination request.

