示例#1
0
def provision(config, session_factory):
    func_config = dict(
        name=config.get('lambda_name', 'cloud-custodian-mailer'),
        description=config.get('lambda_description', 'Cloud Custodian Mailer'),
        tags=config.get('lambda_tags', {}),
        handler='periodic.dispatch',
        runtime=config['runtime'],
        memory_size=config['memory'],
        timeout=config['timeout'],
        role=config['role'],
        subnets=config['subnets'],
        security_groups=config['security_groups'],
        dead_letter_config=config.get('dead_letter_config', {}),
        events=[
            CloudWatchEventSource(
                {
                    'type': 'periodic',
                    'schedule': config.get('lambda_schedule',
                                           'rate(5 minutes)')
                }, session_factory)
        ])

    archive = get_archive(config)
    func = LambdaFunction(func_config, archive)
    log.info("Provisioning mailer lambda %s" % (session_factory().region_name))
    manager = LambdaManager(session_factory)
    manager.publish(func)
def provision(config, session_factory):
    func_config = dict(name='cloud-custodian-mailer',
                       description='Cloud Custodian Mailer',
                       handler='periodic.dispatch',
                       runtime='python2.7',
                       memory_size=config['memory'],
                       timeout=config['timeout'],
                       role=config['role'],
                       subnets=config['subnets'],
                       security_groups=config['security_groups'],
                       dead_letter_config=config.get('dead_letter_config', {}),
                       events=[
                           CloudWatchEventSource(
                               {
                                   'type': 'periodic',
                                   'schedule': 'rate(5 minutes)'
                               },
                               session_factory,
                               prefix="")
                       ])

    archive = get_archive(config)
    func = LambdaFunction(func_config, archive)
    manager = LambdaManager(session_factory)
    manager.publish(func)