Skip to content

Instantly share code, notes, and snippets.

@epequeno
Created May 8, 2019 20:54
Show Gist options
  • Save epequeno/4b9b4256676443fa7704e95f3a079ca7 to your computer and use it in GitHub Desktop.
Save epequeno/4b9b4256676443fa7704e95f3a079ca7 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