def ec2(account, region): try: c = connect(account, region, 'ec2') instances = c.get_only_instances() return render_template('ec2.html', region=region, instances=instances) except Exception, e: return render_template('unauthorized.html', account=account)
def get_template(account, region, stack_name): c = connect(account, region, 'cloudformation') template = c.get_template(stack_name) template = template["GetTemplateResponse"]["GetTemplateResult"]["TemplateBody"] response = make_response(template) response.headers["Content-Disposition"] = "attachment; filename=%s.json" % stack_name return response
def ebs(account, region): try: c = connect(account, region, 'ebs') volumes = c.get_all_volumes() return render_template('ebs.html', volumes=volumes) except Exception, e: return render_template('unauthorized.html', account=account)
def snapshots(account, region): try: c = connect(account, region, 'ec2') snapshots = c.get_all_snapshots(owner='self') return render_template('snapshots.html', region=region, snapshots=snapshots) except Exception, e: return render_template('unauthorized.html', account=account)
def cloudformation(account, region): try: c = connect(account, region, 'cloudformation') stacks = c.describe_stacks() return render_template('cloudformation.html', stacks=stacks) except Exception, e: return render_template('unauthorized.html', account=account)
def autoscale(account, region): try: c = connect(account, region, 'autoscale') asg = c.get_all_groups() return render_template('asg.html', region=region, asg=asg) except Exception, e: return render_template('unauthorized.html', account=account)
def rds(account, region): try: c = connect(account, region, 'rds') db_instances = c.get_all_dbinstances() return render_template('rds.html', db_instances=db_instances) except Exception, e: return render_template('unauthorized.html', account=account)
def elb(account, region): try: c = connect(account, region, 'elb') elb = c.get_all_load_balancers() return render_template('elb.html', region=region, elb=elb) except Exception, e: return render_template('unauthorized.html', account=account)
def sgaudit(account, region): try: c = connect(account, region, 'ec2') report, empty_groups = get_reports(c) return render_template('sgaudit.html', report=report) except Exception, e: return render_template('unauthorized.html', account=account)
def sns(account, region): try: c = connect(account, region, 'sns') subscriptions = c.get_all_subscriptions() subscriptions = subscriptions['ListSubscriptionsResponse']['ListSubscriptionsResult']['Subscriptions'] return render_template('sns.html', subscriptions=subscriptions) except Exception, e: return render_template('unauthorized.html', account=account)
def elasticache(account, region): try: c = connect(account, region, 'elasticache') clusters = c.describe_cache_clusters(show_cache_node_info=True) clusters = clusters['DescribeCacheClustersResponse']['DescribeCacheClustersResult']['CacheClusters'] return render_template('elasticache.html', region=region, clusters=clusters) except Exception, e: return render_template('unauthorized.html', account=account)
def elasticache(account, region): c = connect(account, region, 'elasticache') clusters = c.describe_cache_clusters(show_cache_node_info=True) clusters = clusters['DescribeCacheClustersResponse'][ 'DescribeCacheClustersResult']['CacheClusters'] return render_template('elasticache.html', region=region, clusters=clusters)
def redshift(account, region): try: c = connect(account, region, 'redshift') clusters = c.describe_clusters() clusters = clusters['DescribeClustersResponse']['DescribeClustersResult']['Clusters'] return render_template('redshift.html', clusters=clusters) except Exception, e: return render_template('unauthorized.html', account=account)
def ami(account, region): c = connect(account,region, 'ec2') amis = c.get_all_images(owners = ['self']) for ami in amis: print dir(ami) print type(ami) ami_list = {ami: c.get_image(ami.id) for ami in amis} return render_template('ami.html', region=region, amis=ami_list)
def ami(account, region): c = connect(account, region, 'ec2') amis = c.get_all_images(owners=['self']) for ami in amis: print dir(ami) print type(ami) ami_list = {ami: c.get_image(ami.id) for ami in amis} return render_template('ami.html', region=region, amis=ami_list)
def dynamodb(account, region): c = connect(account, region, 'dynamodb') tables = c.list_tables() if tables: tables = [c.describe_table(x) for x in tables] else: tables = list() return render_template('dynamodb.html', tables=tables)
def ami(account, region): try: c = connect(account,region, 'ec2') amis = c.get_all_images(owners = ['self']) ami_list = {ami: c.get_image(ami.id) for ami in amis} return render_template('ami.html', region=region, amis=ami_list) except Exception, e: return render_template('unauthorized.html', account=account)
def sg(account, region, id): try: c = connect(account, region,'ec2') sg = c.get_all_security_groups(filters={'group-id': id}) sg = add_description(sg) return render_template('sg.html', region=region, sg=sg) except Exception, e: return render_template('unauthorized.html', account=account)
def get_template(account, region, stack_name): c = connect(account, region, 'cloudformation') template = c.get_template(stack_name) template = template["GetTemplateResponse"]["GetTemplateResult"][ "TemplateBody"] response = make_response(template) response.headers[ "Content-Disposition"] = "attachment; filename=%s.json" % stack_name return response
def sgaudit_account_monitor(account=None, region=None): if account == None or region == None: return jsonify(error='account and region required') monitor = dict() c = connect(account, region, 'ec2') report, empty_groups = get_reports(c) security_alert = False if report: security_alert = report return jsonify(audit={account: {region: security_alert}})
def sqs(account, region): c = connect(account, region, 'sqs') queues = list() all_queues = c.get_all_queues() for q in all_queues: url = 'https://sqs.%s.amazonaws.com%s' % (region, q.id) attributes = q.get_attributes() attributes['url'] = url queues.append(attributes) return render_template('sqs.html', queues=queues)
def get_template(account, region, stack_name): try: c = connect(account, region, 'cloudformation') template = c.get_template(stack_name) template = template["GetTemplateResponse"]["GetTemplateResult"]["TemplateBody"] response = make_response(template) response.headers["Content-Disposition"] = "attachment; filename=%s.json" % stack_name return response except Exception, e: return render_template('unauthorized.html', account=account)
def dynamodb(account, region): try: c = connect(account, region, 'dynamodb') tables = c.list_tables() if tables: tables = [c.describe_table(x) for x in tables] else: tables = list() return render_template('dynamodb.html', tables=tables) except Exception, e: return render_template('unauthorized.html', account=account)
def sgaudit_monitor(): monitor = dict() for account in current_app.config['CONFIG']['accounts']: monitor[account] = dict() for region in current_app.config['CONFIG']['regions']: c = connect(account, region, 'ec2') report, empty_groups = get_reports(c) if report: monitor[account][region] = True else: monitor[account][region] = False return jsonify(sgaudit=monitor)
def route53(account, region): c = connect(account, region, 'route53') c = list(c) conn = c.pop(0) d = list() r = list() for hzitem in c[0]: d.append(hzitem) try: records = conn.get_all_rrsets(hzitem) paginate = True while paginate: for item in records: r.append(item) paginate = records.next_token except: domain = None d = d[::2] return render_template('r53.html', domains=d, records=r)
def snapshots(account, region): c = connect(account, region, 'ec2') snapshots = c.get_all_snapshots(owner='self') return render_template('snapshots.html', region=region, snapshots=snapshots)
def ebs(account, region): c = connect(account, region, 'ebs') volumes = c.get_all_volumes() return render_template('ebs.html', volumes=volumes)
def ec2(account, region): c = connect(account, region, 'ec2') instances = c.get_only_instances() return render_template('ec2.html', region=region, instances=instances)
def sgaudit(account, region): c = connect(account, region, 'ec2') report, empty_groups = get_reports(c) return render_template('sgaudit.html', report=report)
def sns(account, region): c = connect(account, region, 'sns') subscriptions = c.get_all_subscriptions() subscriptions = subscriptions['ListSubscriptionsResponse']['ListSubscriptionsResult']['Subscriptions'] return render_template('sns.html', subscriptions=subscriptions)
def rds(account, region): c = connect(account, region, 'rds') db_instances = c.get_all_dbinstances() return render_template('rds.html', db_instances=db_instances)
def sg(account, region, id): c = connect(account, region, 'ec2') sg = c.get_all_security_groups(filters={'group-id': id}) sg = add_description(sg) return render_template('sg.html', region=region, sg=sg)
def elasticache(account, region): c = connect(account, region, 'elasticache') clusters = c.describe_cache_clusters(show_cache_node_info=True) clusters = clusters['DescribeCacheClustersResponse']['DescribeCacheClustersResult']['CacheClusters'] return render_template('elasticache.html', region=region, clusters=clusters)
def sg(account, region, id): c = connect(account, region,'ec2') sg = c.get_all_security_groups(filters={'group-id': id}) return render_template('sg.html', region=region, sg=sg)
def elb(account, region): c = connect(account, region, 'elb') elb = c.get_all_load_balancers() return render_template('elb.html', region=region, elb=elb)
def asg(account, region): c = connect(account, region, 'autoscale') asg = c.get_all_groups() return render_template('asg.html', region=region, asg=asg)
def iam(account, region): c = connect(account, region, 'iam') users = c.get_all_users() users = users['list_users_response']['list_users_result']['users'] return render_template('iam.html', users=users)
def cloudformation(account, region): c = connect(account, region, 'cloudformation') stacks = c.describe_stacks() return render_template('cloudformation.html', stacks=stacks)
def redshift(account, region): c = connect(account, region, 'redshift') clusters = c.describe_clusters() clusters = clusters['DescribeClustersResponse']['DescribeClustersResult']['Clusters'] return render_template('redshift.html', clusters=clusters)