Ejemplo n.º 1
0
def get_function(session_factory, role, buckets=None):
    from c7n.mu import (LambdaFunction, custodian_archive, BucketNotification)

    config = dict(name='c7n-s3-encrypt',
                  handler='s3crypt.process_key_event',
                  memory_size=256,
                  timeout=15,
                  role=role,
                  runtime="python2.7",
                  description='Custodian S3 Key Encrypt')

    if buckets:
        config['events'] = [
            BucketNotification({}, session_factory, b) for b in buckets
        ]

    archive = custodian_archive()
    archive.create()

    src = __file__
    if src.endswith('.pyc'):
        src = src[:-1]

    archive.add_file(src, 's3crypt.py')
    archive.add_contents('config.json', json.dumps({}))
    archive.close()
    return LambdaFunction(config, archive)
Ejemplo n.º 2
0
def get_function(session_factory, role, buckets=None, account_id=None):
    from c7n.mu import (LambdaFunction, custodian_archive, BucketNotification)

    config = dict(name='c7n-s3-encrypt',
                  handler='s3crypt.process_key_event',
                  memory_size=256,
                  timeout=30,
                  role=role,
                  runtime="python2.7",
                  description='Custodian S3 Key Encrypt')

    if buckets:
        config['events'] = [
            BucketNotification({'account_s3': account_id}, session_factory, b)
            for b in buckets
        ]

    archive = custodian_archive()

    archive.add_py_file(__file__)
    archive.add_contents('config.json', json.dumps({}))
    archive.close()
    return LambdaFunction(config, archive)
Ejemplo n.º 3
0
 def process_bucket(self, f, b):
     from c7n.mu import BucketNotification
     source = BucketNotification({}, self.manager.session_factory, b)
     return source.add(f)
Ejemplo n.º 4
0
 def process_bucket(self, func, bucket, account_id, session_factory):
     from c7n.mu import BucketNotification
     source = BucketNotification({'account_s3': account_id},
                                 session_factory, bucket)
     return source.add(func)
Ejemplo n.º 5
0
 def process_bucket(self, func, bucket, account_id, session_factory):
     from c7n.mu import BucketNotification
     source = BucketNotification(
         {'account_s3': account_id}, session_factory, bucket)
     return source.add(func)
Ejemplo n.º 6
0
 def process_bucket(self, f, b):
     from c7n.mu import BucketNotification
     source = BucketNotification({}, self.manager.session_factory, b)
     return source.add(f)