~cyplo/dotfiles

ref: 83ddcc09dc68389b129d598722eca9e90a6dff33 dotfiles/tools/find-iam-user-for-access-key.py -rw-r--r-- 541 bytes
83ddcc09 — Cyryl Płotnicki remove broken i3 msg call 1 year, 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import boto.iam
import sys

iam = boto.connect_iam()

users = iam.get_all_users('/')['list_users_response']['list_users_result']['users']

for user in users:
    for key_result in iam.get_all_access_keys(user['user_name'])['list_access_keys_response']['list_access_keys_result']['access_key_metadata']:
            aws_access_key = key_result['access_key_id']
            for TARGET_ACCESS_KEY in sys.argv[1:]:
                if aws_access_key == TARGET_ACCESS_KEY:
                        print aws_access_key + ' : ' + user['user_name']