Last active
August 9, 2021 19:40
-
-
Save pandeybk/d643bef54007db831754 to your computer and use it in GitHub Desktop.
Find all IAM Users and assigned groups boto3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
iam = boto3.client('iam') | |
def find_user_and_groups(): | |
for userlist in iam.list_users()['Users']: | |
userGroups = iam.list_groups_for_user(UserName=userlist['UserName']) | |
print("Username: " + userlist['UserName']) | |
print("Assigned groups: ") | |
for groupName in userGroups['Groups']: | |
print(groupName['GroupName']) | |
print("----------------------------") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment