-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathawsconsol.py
57 lines (51 loc) · 2.36 KB
/
awsconsol.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
File: awsconsol.py
Author: Rafal Marguzewicz (PGS Software)
Email: [email protected]
Gitlab:
Description: Mangament hooking
"""
from argparse import ArgumentParser, RawDescriptionHelpFormatter
from iam.iam import Iam
from ec2.ec2 import Ec2
from s3.s3 import S3
from elb.elb import Elb
from rds.rds import Rds
from dynamodb.dynamodb import Dynamodb
from migrate import Migrate
from awslambda.awslambda import Lambda
SERVICES: list = ['ec2', 'iam', 's3', 'elb', 'lambda', 'rds', 'migrate', 'dynamodb']
if __name__ == "__main__":
Arg = ArgumentParser(
prog='awsconsole.py',
formatter_class=RawDescriptionHelpFormatter,
description='''CLI Manager fetures:''',
epilog='''
examples:
python3 awsconsole.py ec2 all
python3 awsconsole.py ec2 all --ebs
python3 awsconsole.py ec2 all --autoscaling
python3 awsconsole.py ec2 find -i i-0552e09b7a54fa2cf
python3 awsconsole.py [rds|elb|lambda] all
''')
Arg.add_argument('service', choices=SERVICES, help="ec2|aim")
Arg.add_argument('action', help="all|find|...")
Arg.add_argument('-i', '--id', help="")
Arg.add_argument('-R', '--running', action='store_true', help="")
Arg.add_argument('-t', '--tags', action='store_true', help="")
Arg.add_argument('-u', '--username', help="Username for AIM role")
Arg.add_argument('-r', '--region_name', help="Username for AIM role")
Arg.add_argument('-o', '--without_owner', action="store_true", help="Ec2 with owner")
Arg.add_argument('--autoscaling', action="store_true", help="Search Autoscaling groups (only EC2)")
Arg.add_argument('--groups', action="store_true", help="Search IAM groups (only IAM")
Arg.add_argument('--ebs', action="store_true", help="Search EBS Volumes (only service ec2)")
Arg.add_argument('-p', '--password', help="to IAM")
Arg.add_argument('--stop', action="store_true", help="Stop one or all instances")
Arg.add_argument('--start', action="store_true", help="Start one or all instances from query")
Arg.add_argument('--terminate', action="store_true", help="Terminate one or all EC2 instances")
Arg.add_argument('--delete', action="store_true", help="Delete RDS, ELB")
p = Arg.parse_args()
'''Generate class name by trick locals()[key]'''
service = locals()[p.service.capitalize()](p)
if 'service' in p and 'action' in p:
getattr(service, p.action)()