pep8 fixes
This commit is contained in:
22
libs/iam.py
22
libs/iam.py
@@ -70,6 +70,7 @@ def check_root_account():
|
||||
except KeyboardInterrupt:
|
||||
print("CTRL-C received, exiting...")
|
||||
|
||||
|
||||
def iam_change_user_console_password(username, password):
|
||||
'''
|
||||
Change the IAM console password of a specified user with the specified password
|
||||
@@ -128,6 +129,7 @@ def get_password_policy():
|
||||
except KeyboardInterrupt:
|
||||
print("CTRL-C received, exiting...")
|
||||
|
||||
|
||||
def iam_create_user(username):
|
||||
'''
|
||||
This creates a IAM user, this does not set a password you need to call the
|
||||
@@ -149,6 +151,7 @@ def iam_create_user(username):
|
||||
except KeyboardInterrupt:
|
||||
print("CTRL-C received, exiting...")
|
||||
|
||||
|
||||
def iam_create_access_key(username):
|
||||
'''
|
||||
Create a new access & secret key for the specified username
|
||||
@@ -164,6 +167,7 @@ def iam_create_access_key(username):
|
||||
except KeyboardInterrupt:
|
||||
print("CTRL-C received, exiting...")
|
||||
|
||||
|
||||
def iam_delete_access_key(username, accesskey):
|
||||
'''
|
||||
Delete the specified access key for the specified user and specified access key
|
||||
@@ -200,6 +204,7 @@ def iam_delete_mfa_device(username, mfaserial):
|
||||
except KeyboardInterrupt:
|
||||
print("CTRL-C received, exiting...")
|
||||
|
||||
|
||||
def iam_list_mfa_device(username):
|
||||
'''
|
||||
List MFA devices for a specified username
|
||||
@@ -230,6 +235,7 @@ def iam_list_mfa_device(username):
|
||||
except KeyboardInterrupt:
|
||||
print("CTRL-C received, exiting...")
|
||||
|
||||
|
||||
def iam_make_admin(username):
|
||||
'''
|
||||
Attach the builtin admin policy to the specified username
|
||||
@@ -249,6 +255,7 @@ def iam_make_admin(username):
|
||||
except KeyboardInterrupt:
|
||||
print("CTRL-C received, exiting...")
|
||||
|
||||
|
||||
def iam_make_backdoor_account(username, password):
|
||||
client = boto3.client('iam', region_name=region)
|
||||
|
||||
@@ -264,6 +271,7 @@ def iam_make_backdoor_account( username, password):
|
||||
except KeyboardInterrupt:
|
||||
print("CTRL-C received, exiting...")
|
||||
|
||||
|
||||
def iam_list_groups():
|
||||
'''
|
||||
List all IAM groups for the account
|
||||
@@ -297,6 +305,7 @@ def iam_list_groups():
|
||||
except KeyboardInterrupt:
|
||||
print("CTRL-C received, exiting...")
|
||||
|
||||
|
||||
def iam_get_user():
|
||||
'''
|
||||
Get user info: userid, arn, created date, password last used
|
||||
@@ -331,6 +340,7 @@ def iam_get_user():
|
||||
except KeyboardInterrupt:
|
||||
print("CTRL-C received, exiting...")
|
||||
|
||||
|
||||
def iam_get_account_summary():
|
||||
'''
|
||||
calls get_account_summary(). This shows numbers of groups, polcies, MFA devices, etc
|
||||
@@ -339,7 +349,6 @@ def iam_get_account_summary():
|
||||
try:
|
||||
for region in regions:
|
||||
client = boto3.client('iam', region_name=region)
|
||||
|
||||
response = client.get_account_summary()
|
||||
# print(response)
|
||||
if response.get('SummaryMap') is None:
|
||||
@@ -363,6 +372,7 @@ def iam_get_account_summary():
|
||||
except KeyboardInterrupt:
|
||||
print("CTRL-C received, exiting...")
|
||||
|
||||
|
||||
def iam_list_users():
|
||||
'''
|
||||
List users for the account
|
||||
@@ -371,7 +381,6 @@ def iam_list_users():
|
||||
try:
|
||||
for region in regions:
|
||||
client = boto3.client('iam', region_name=region)
|
||||
|
||||
response = client.list_users()
|
||||
# print(response)
|
||||
if response.get('Users') is None:
|
||||
@@ -404,7 +413,6 @@ def iam_list_roles():
|
||||
try:
|
||||
for region in regions:
|
||||
client = boto3.client('iam', region_name=region)
|
||||
|
||||
response = client.list_roles()
|
||||
# print(response)
|
||||
if response.get('Roles') is None:
|
||||
@@ -440,7 +448,6 @@ def iam_list_policies():
|
||||
try:
|
||||
for region in regions:
|
||||
client = boto3.client('iam', region_name=region)
|
||||
|
||||
response = client.list_policies()
|
||||
# print(response)
|
||||
if response.get('Policies') is None:
|
||||
@@ -467,6 +474,7 @@ def iam_list_policies():
|
||||
except KeyboardInterrupt:
|
||||
print("CTRL-C received, exiting...")
|
||||
|
||||
|
||||
def iam_list_policies_attached():
|
||||
'''
|
||||
Lists all the managed policies that are available in your AWS account, including your own customer-defined managed policies and all AWS managed policies.
|
||||
@@ -476,7 +484,6 @@ def iam_list_policies_attached():
|
||||
try:
|
||||
for region in regions:
|
||||
client = boto3.client('iam', region_name=region)
|
||||
|
||||
response = client.list_policies(OnlyAttached=True)
|
||||
# print(response)
|
||||
if response.get('Policies') is None:
|
||||
@@ -512,7 +519,6 @@ def iam_list_user_policies(username):
|
||||
try:
|
||||
for region in regions:
|
||||
client = boto3.client('iam', region_name=region)
|
||||
|
||||
response = client.list_user_policies(UserName=username)
|
||||
# print(response)
|
||||
if response.get('PolicyNames') is None:
|
||||
@@ -539,6 +545,7 @@ def iam_list_user_policies(username):
|
||||
except KeyboardInterrupt:
|
||||
print("CTRL-C received, exiting...")
|
||||
|
||||
|
||||
def iam_list_attached_user_policies(username):
|
||||
'''
|
||||
Lists all managed policies that are attached to the specified IAM user.
|
||||
@@ -547,7 +554,6 @@ def iam_list_attached_user_policies(username):
|
||||
try:
|
||||
for region in regions:
|
||||
client = boto3.client('iam', region_name=region)
|
||||
|
||||
response = client.list_attached_user_policies(UserName=username)
|
||||
# print(response)
|
||||
if response.get('AttachedPolicies') is None:
|
||||
@@ -574,6 +580,7 @@ def iam_list_attached_user_policies(username):
|
||||
except KeyboardInterrupt:
|
||||
print("CTRL-C received, exiting...")
|
||||
|
||||
|
||||
def iam_list_entities_for_policy(policy_arn):
|
||||
'''
|
||||
Lists all IAM users, groups, and roles that the specified managed policy is attached to.
|
||||
@@ -582,7 +589,6 @@ def iam_list_entities_for_policy(policy_arn):
|
||||
try:
|
||||
for region in regions:
|
||||
client = boto3.client('iam', region_name=region)
|
||||
|
||||
response = client.list_entities_for_policy(PolicyArn=policy_arn)
|
||||
print(response)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user