def get_function(session_factory, options, groups): config = dict(name='cloud-maid-error-notify', handler='logsub.process_log_event', runtime='python2.7', memory_size=512, timeout=15, role=options.role, description='Maid Error Notify', events=[ CloudWatchLogSubscription(session_factory, groups, options.pattern) ]) archive = PythonPackageArchive( # Directory to lambda file os.path.join(os.path.dirname(inspect.getabsfile(c7n)), 'logsub.py'), # Don't include virtualenv deps lib_filter=lambda x, y, z: ([], [])) archive.create() archive.add_contents( 'config.json', json.dumps({ 'topic': options.topic, 'subject': options.subject })) archive.close() return LambdaFunction(config, archive)
def get_function(session_factory, name, role, sns_topic, log_groups, subject="Lambda Error", pattern="Traceback"): """Lambda function provisioning. Self contained within the component, to allow for easier reuse. """ # Lazy import to avoid runtime dependency from c7n.mu import ( LambdaFunction, PythonPackageArchive, CloudWatchLogSubscription) config = dict( name=name, handler='logsub.process_log_event', runtime='python2.7', memory_size=512, timeout=15, role=role, description='Custodian Ops Error Notify', events=[ CloudWatchLogSubscription( session_factory, log_groups, pattern)]) archive = PythonPackageArchive() archive.add_py_file(__file__) archive.add_contents( 'config.json', json.dumps({ 'topic': sns_topic, 'subject': subject })) archive.close() return LambdaFunction(config, archive)
def get_function(session_factory, name, role, log_groups, project, account_name, account_id, pattern="Traceback"): """Lambda function provisioning. Self contained within the component, to allow for easier reuse. """ # Lazy import to avoid runtime dependency import inspect import os import c7n from c7n.mu import (LambdaFunction, PythonPackageArchive, CloudWatchLogSubscription) config = dict(name=name, runtime='python2.7', memory_size=512, timeout=15, role=role, description='Custodian Sentry Relay', events=[ CloudWatchLogSubscription(session_factory, log_groups, pattern) ]) archive = PythonPackageArchive( # Directory to lambda file os.path.join(os.path.dirname(inspect.getabsfile(c7n)), 'ufuncs', 'cwl2sentry.py'), # Don't include virtualenv deps lib_filter=lambda x, y, z: ([], [])) archive.create() archive.add_contents( 'config.json', json.dumps({ 'project': project, 'account_name': account_name, 'account_id': account_id })) archive.close() return LambdaFunction(config, archive)
def get_function(session_factory, name, handler, role, log_groups, project, account_name, account_id, sentry_dsn, pattern="Traceback"): """Lambda function provisioning. Self contained within the component, to allow for easier reuse. """ # Lazy import to avoid runtime dependency from c7n.mu import (LambdaFunction, PythonPackageArchive, CloudWatchLogSubscription) config = dict(name=name, handler=handler, runtime='python2.7', memory_size=512, timeout=15, role=role, description='Custodian Sentry Relay', events=[ CloudWatchLogSubscription(session_factory, log_groups, pattern) ]) archive = PythonPackageArchive(os.path.dirname(__file__), skip='*.pyc', lib_filter=lambda x, y, z: ([], [])) archive.create() archive.add_contents( 'config.json', json.dumps({ 'project': project, 'account_name': account_name, 'account_id': account_id, 'sentry_dsn': sentry_dsn, })) archive.add_contents('handler.py', 'from c7n_sentry.c7nsentry import process_log_event') archive.close() return LambdaFunction(config, archive)
def get_function(session_factory, name, role, sns_topic, log_groups, subject="Lambda Error", pattern="Traceback"): """Lambda function provisioning. Self contained within the component, to allow for easier reuse. """ # Lazy import to avoid runtime dependency import inspect import os import c7n from c7n.mu import (LambdaFunction, PythonPackageArchive, CloudWatchLogSubscription) config = dict(name=name, handler='logsub.process_log_event', runtime='python2.7', memory_size=512, timeout=15, role=role, description='Custodian Ops Error Notify', events=[ CloudWatchLogSubscription(session_factory, log_groups, pattern) ]) archive = PythonPackageArchive( # Directory to lambda file os.path.join(os.path.dirname(inspect.getabsfile(c7n)), 'ufuncs', 'logsub.py'), # Don't include virtualenv deps lib_filter=lambda x, y, z: ([], [])) archive.create() archive.add_contents('config.json', json.dumps({ 'topic': sns_topic, 'subject': subject })) archive.close() return LambdaFunction(config, archive)