Created
May 8, 2019 20:54
-
-
Save epequeno/4b9b4256676443fa7704e95f3a079ca7 to your computer and use it in GitHub Desktop.
basic aws config rule example
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
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