I am still in the learning phase of boto3 and I can't seem to figure out the basics as to get the list of policies assigned to a user using boto3 for an aws profile?
For example:
>> import boto3
>> client=boto3.client('iam')
>> client.get_user()
Here, client.get_user()
doesn't give me the policy attribute.
Thanks
Under the AWS Management Console section, choose the role you want to view. On the Selected role page, under Manage users and groups for this role, you can view the users and groups assigned to the role.
For more information about ARNs, go to Amazon Resource Names (ARNs) in the Amazon Web Services General Reference . The path to the policy. For more information about paths, see IAM identifiers in the IAM User Guide . The identifier for the version of the policy that is set as the default version.
00:00 Boto3's primary function is to make AWS API calls for you. It extracts these APIs in two main ways: clients and resources. Clients give you low-level service access, while resources provide an object-oriented way of working with these services.
I know this is an old question, but what you want is:
For inline policies:
inline_user_policies = client.list_user_policies(UserName=user_name)
For managed policies:
managed_user_policies = client.list_attached_user_policies(UserName=user_name)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With