예제 #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
파일: api.py 프로젝트: JMassapina/elastatus
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)