示例#1
0
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)
示例#2
0
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
示例#3
0
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)
示例#4
0
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)
示例#5
0
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)
示例#6
0
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)
示例#7
0
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)
示例#8
0
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)
示例#9
0
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)
示例#10
0
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)
示例#11
0
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)
示例#12
0
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)
示例#13
0
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)
示例#14
0
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)
示例#15
0
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)
示例#16
0
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)
示例#17
0
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)
示例#18
0
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)
示例#19
0
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)
示例#20
0
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
示例#21
0
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}})
示例#22
0
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)
示例#23
0
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)
示例#24
0
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)
示例#25
0
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)
示例#26
0
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)
示例#27
0
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)
示例#28
0
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)
示例#29
0
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)
示例#30
0
def ebs(account, region):
    c = connect(account, region, 'ebs')
    volumes = c.get_all_volumes()
    return render_template('ebs.html', volumes=volumes)
示例#31
0
def ec2(account, region):
    c = connect(account, region, 'ec2')
    instances = c.get_only_instances()
    return render_template('ec2.html', region=region, instances=instances)
示例#32
0
def sgaudit(account, region):
    c = connect(account, region, 'ec2')
    report, empty_groups = get_reports(c)
    return render_template('sgaudit.html', report=report)
示例#33
0
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)
示例#34
0
def rds(account, region):
    c = connect(account, region, 'rds')
    db_instances = c.get_all_dbinstances()
    return render_template('rds.html', db_instances=db_instances)
示例#35
0
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)
示例#36
0
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)
示例#37
0
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)
示例#38
0
def elb(account, region):
    c = connect(account, region, 'elb')
    elb = c.get_all_load_balancers()
    return render_template('elb.html', region=region, elb=elb)
示例#39
0
def asg(account, region):
    c = connect(account, region, 'autoscale')
    asg = c.get_all_groups()
    return render_template('asg.html', region=region, asg=asg)
示例#40
0
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)
示例#41
0
def ebs(account, region):
    c = connect(account, region, 'ebs')
    volumes = c.get_all_volumes()
    return render_template('ebs.html', volumes=volumes)
示例#42
0
def ec2(account, region):
    c = connect(account, region, 'ec2')
    instances = c.get_only_instances()
    return render_template('ec2.html', region=region, instances=instances)
示例#43
0
def asg(account, region):
    c = connect(account, region, 'autoscale')
    asg = c.get_all_groups()
    return render_template('asg.html', region=region, asg=asg)
示例#44
0
def elb(account, region):
    c = connect(account, region, 'elb')
    elb = c.get_all_load_balancers()
    return render_template('elb.html', region=region, elb=elb)
示例#45
0
def rds(account, region):
    c = connect(account, region, 'rds')
    db_instances = c.get_all_dbinstances()
    return render_template('rds.html', db_instances=db_instances)
示例#46
0
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)
示例#47
0
def sgaudit(account, region):
    c = connect(account, region, 'ec2')
    report, empty_groups = get_reports(c)
    return render_template('sgaudit.html', report=report)
示例#48
0
def cloudformation(account, region):
    c = connect(account, region, 'cloudformation')
    stacks = c.describe_stacks()
    return render_template('cloudformation.html', stacks=stacks)
示例#49
0
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)