Created
August 29, 2017 20:41
-
-
Save libertyy/8584acf824b1508ee8f31d65e0b00836 to your computer and use it in GitHub Desktop.
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
import boto3 | |
import base64 | |
import time | |
import csv | |
client = boto3.client('iam') | |
### Credentials Report | |
response = client.generate_credential_report() | |
while (response['State'] != 'COMPLETE'): | |
time.sleep(1) | |
response = client.generate_credential_report() | |
response = client.get_credential_report() | |
report = str.splitlines(response['Content']) | |
# Users from Group | |
response = client.get_group( | |
GroupName='InfoScout-devEngineer' | |
) | |
users = map(lambda x: x['UserName'], response['Users'] ) | |
reader = csv.reader(report, delimiter=',') | |
header = reader.next() | |
#print header | |
for row in reader: | |
if row[0] in users and row[7].lower() == 'false': | |
print row[0], row[7] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment