Skip to content

Instantly share code, notes, and snippets.

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