generated from ApeWorX/project-template
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding admin features and kms create and delete
- Loading branch information
1 parent
be35442
commit 2d0fe60
Showing
5 changed files
with
95 additions
and
42 deletions.
There are no files selected for viewing
This file contains 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
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import boto3 | ||
import click | ||
|
||
|
||
@click.group("admin") | ||
def admin(): | ||
"""Manage AWS Admin information""" | ||
|
||
|
||
@admin.command() | ||
def list_admins(): | ||
iam_client = boto3.client('iam') | ||
response = iam_client.list_users() | ||
admins = [] | ||
for user in response['Users']: | ||
user_name = user['UserName'] | ||
user_policies = iam_client.list_attached_user_policies(UserName=user_name) | ||
for policy in user_policies['AttachedPolicies']: | ||
if policy['PolicyName'] == 'AdministratorAccess': | ||
admins.append(user_name) | ||
|
||
click.echo(f'Administrators: {admins}') | ||
|
||
|
||
@admin.command() | ||
def list_users(): | ||
iam_client = boto3.client('iam') | ||
response = iam_client.list_users() | ||
click.echo(f'Users: {response.get("Users")}') | ||
|
||
|
||
@admin.command() | ||
@click.option('--dictionary', '-d', multiple=True) | ||
def check_this(dictionary): | ||
print(dictionary) |
This file contains 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
This file contains 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