Пример #1
0
# Prints a list of all access keys with the associated user.

import boto
from boto.iam.connection import IAMConnection

cfn = IAMConnection()
data = cfn.get_all_users()
for user in data.list_users_result.users:
    for ak in cfn.get_all_access_keys(
            user.user_name).list_access_keys_result.access_key_metadata:
        print user.user_name + ': ' + ak.access_key_id
Пример #2
0
                    iam.delete_group_policy(group_name, policy)
                iam.delete_group(group_name)
            if not group_exists or destructive:
                print "INITIALIZE: Group %s does not exist, creating" % (
                    group_name,)
                group = iam.create_group(group_name)
                print "INITIALIZE: Adding policy %s to group %s" % (
                    policy_name, group_name)
                iam.put_group_policy(group_name, policy_name, policy_json)

            # 2) Check if IAM user 'can-opener-user' exists, if not,
            # create, set to group 'can-opener-grp', get credentials
            # and print them out.
            user_exists = user_name in [u.user_name for u in iam.get_all_users().list_users_response.list_users_result.users]
            if user_exists and destructive:
                for key in iam.get_all_access_keys(user_name).list_access_keys_response.list_access_keys_result.access_key_metadata:
                    print "DESTROY: Destroying access key %s of user %s" % (
                        key.access_key_id, user_name)
                    iam.delete_access_key(key.access_key_id, user_name)
                print "DESTROY: Destructing old user %s" % (user_name,)
                iam.delete_user(user_name)
            if not user_exists or destructive:
                print "INIITALIZE: User %s does not exist, creating" % (
                    user_name,)
                user = iam.create_user(user_name)
                print "INITIALIZE: Adding user %s to group %s" % (
                    user_name, group_name)
                iam.add_user_to_group(group_name, user_name)
                print "INITIALIZE: Creating new access key for user %s" % (
                    user_name,)
                key = iam.create_access_key(user_name).create_access_key_response.create_access_key_result.access_key
# Prints a list of all access keys with the associated user.

import boto
from boto.iam.connection import IAMConnection

cfn = IAMConnection()
data = cfn.get_all_users()
for user in data.list_users_result.users:
  for ak in cfn.get_all_access_keys(user.user_name).list_access_keys_result.access_key_metadata:
    print user.user_name + ': ' + ak.access_key_id