-
-
Save brandoncruz3/87db57e1d8342a03b9f2417c62ee9400 to your computer and use it in GitHub Desktop.
Find all IAM Users and assigned groups boto3
This file contains 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