简体   繁体   中英

How to list AWS managed policy attached to a role using boto3

I am trying to list policies attached to a role using boto3. I am using list_role_policies or get_role_policy for that. But it only lists inline policies attached to the role and doesn't list AWS managed policies attached to it. is there any way we can list all the policies attached to a role (inline as well as AWS managed) using boto3.

Below is a code snippet using list_role_policies

import boto3
from botocore.exceptions import ClientError

ec2=boto3.client('ec2',region_name='ca-central-1')
iam=boto3.client('iam')


response = iam.list_role_policies(RoleName='rolename')
print(response)

Thanks

I dont think we have anything as such. Need to use both 'list_role_policies'('to list inline policies') and 'list_attached_role_policies'(to list managed policies)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM