Skip to content

Instantly share code, notes, and snippets.

@anarquias
Forked from epequeno/iam.py
Created July 3, 2019 08:08
Show Gist options
  • Save anarquias/6cf02e73268f1b07596c9ea19639c0a4 to your computer and use it in GitHub Desktop.
Save anarquias/6cf02e73268f1b07596c9ea19639c0a4 to your computer and use it in GitHub Desktop.
basic aws config rule example
def evaluate_compliance(event, configuration_item, valid_rule_parameters):
iam = get_client('iam', event)
users = get_all_users(iam)
evaluations = []
for user in users:
e = build_evaluation(user["UserId"], 'COMPLIANT', event, annotation="testing")
evaluations.append(e)
return evaluations
def get_all_users(client):
list_to_return = []
user_list = client.list_users()
while True:
for user in user_list['Users']:
list_to_return.append(user)
if 'Marker' in user_list:
user_list = client.list_users(Marker=user_list['Marker'])
else:
break
return list_to_return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment