Exemplo n.º 1
0
    def __new__(cls, name, parents, attrs):
        if 'filter_registry' not in attrs:
            attrs['filter_registry'] = FilterRegistry('%s.filters' %
                                                      name.lower())
        if 'action_registry' not in attrs:
            actions = ActionRegistry('%s.actions' % name.lower())
            actions.register('tag', Tag)
            attrs['action_registry'] = actions

        return super(QueryMeta, cls).__new__(cls, name, parents, attrs)
Exemplo n.º 2
0
    def __new__(cls, name, parents, attrs):
        if 'filter_registry' not in attrs:
            attrs['filter_registry'] = FilterRegistry('%s.filters' %
                                                      name.lower())
        if 'action_registry' not in attrs:
            actions = ActionRegistry('%s.actions' % name.lower())

            # All ARM resources will have tag support; however, classic resources may not have support
            actions.register('tag', Tag)
            attrs['action_registry'] = actions

        return super(QueryMeta, cls).__new__(cls, name, parents, attrs)
Exemplo n.º 3
0
    def __new__(cls, name, parents, attrs):
        if 'filter_registry' not in attrs:
            attrs['filter_registry'] = FilterRegistry(
                '%s.filters' % name.lower())
        if 'action_registry' not in attrs:
            actions = ActionRegistry(
                '%s.actions' % name.lower())

            # All ARM resources will have tag support; however, classic resources may not have support
            actions.register('tag', Tag)
            attrs['action_registry'] = actions

        return super(QueryMeta, cls).__new__(cls, name, parents, attrs)
Exemplo n.º 4
0
from c7n.query import QueryResourceManager, ResourceQuery
from c7n.tags import RemoveTag, Tag, TagActionFilter, TagDelayedAction
from c7n.utils import (chunks, local_session, set_annotation, type_schema,
                       dumps, get_account_id)
"""
TODO:
 - How does replication status effect in place encryption.
 - Test glacier support
"""

log = logging.getLogger('custodian.s3')

filters = FilterRegistry('s3.filters')
actions = ActionRegistry('s3.actions')
filters.register('marked-for-op', TagActionFilter)
actions.register('auto-tag-user', AutoTagUser)

MAX_COPY_SIZE = 1024 * 1024 * 1024 * 2


@resources.register('s3')
class S3(QueryResourceManager):

    #resource_type = "aws.s3.bucket"

    class resource_type(ResourceQuery.resolve("aws.s3.bucket")):
        dimension = 'BucketName'

    executor_factory = executor.ThreadPoolExecutor
    filter_registry = filters
    action_registry = actions
Exemplo n.º 5
0
from c7n.tags import RemoveTag, Tag, TagActionFilter, TagDelayedAction
from c7n.utils import (
    chunks, local_session, set_annotation, type_schema, dumps, get_account_id)

"""
TODO:
 - How does replication status effect in place encryption.
 - Test glacier support
"""

log = logging.getLogger('custodian.s3')

filters = FilterRegistry('s3.filters')
actions = ActionRegistry('s3.actions')
filters.register('marked-for-op', TagActionFilter)
actions.register('auto-tag-user', AutoTagUser)

MAX_COPY_SIZE = 1024 * 1024 * 1024 * 2


@resources.register('s3')
class S3(QueryResourceManager):

    #resource_type = "aws.s3.bucket"

    class resource_type(ResourceQuery.resolve("aws.s3.bucket")):
        dimension = 'BucketName'

    executor_factory = executor.ThreadPoolExecutor
    filter_registry = filters
    action_registry = actions
Exemplo n.º 6
0

def _add_appelb_tags(albs, session_factory, ts):
    client = local_session(session_factory).client('elbv2')
    client.add_tags(ResourceArns=[alb['LoadBalancerArn'] for alb in albs],
                    Tags=ts)


def _remove_appelb_tags(albs, session_factory, tag_keys):
    client = local_session(session_factory).client('elbv2')
    client.remove_tags(ResourceArns=[alb['LoadBalancerArn'] for alb in albs],
                       TagKeys=tag_keys)


filters.register('shield-enabled', IsShieldProtected)
actions.register('set-shield', SetShieldProtection)


@filters.register('metrics')
class AppElbMetrics(MetricsFilter):
    """Filter app load balancer by metric values.

    See available metrics here: https://goo.gl/TLQ9Fr
    Custodian defaults to specifying dimensions for the app elb only.
    Target Group dimension not supported atm.
    """
    def get_dimensions(self, resource):
        return [{
            'Name':
            self.model.dimension,
            'Value':
Exemplo n.º 7
0
def _add_appelb_tags(albs, session_factory, ts):
    client = local_session(session_factory).client('elbv2')
    client.add_tags(
        ResourceArns=[alb['LoadBalancerArn'] for alb in albs],
        Tags=ts)


def _remove_appelb_tags(albs, session_factory, tag_keys):
    client = local_session(session_factory).client('elbv2')
    client.remove_tags(
        ResourceArns=[alb['LoadBalancerArn'] for alb in albs],
        TagKeys=tag_keys)


filters.register('shield-enabled', IsShieldProtected)
actions.register('set-shield', SetShieldProtection)


@filters.register('metrics')
class AppElbMetrics(MetricsFilter):
    """Filter app load balancer by metric values.

    See available metrics here: https://goo.gl/TLQ9Fr
    Custodian defaults to specifying dimensions for the app elb only.
    Target Group dimension not supported atm.
    """

    def get_dimensions(self, resource):
        return [{
            'Name': self.model.dimension,
            'Value': 'app/%s/%s' % (