Exemplo n.º 1
0
def function_handler(event, context):
    ''' Lambda handler to manage AWS Greengrass FunctionDefinition resources. '''
    global logger
    logger = crhelper.log_config(event)

    def clean_func(function):
        res = function
        res = keypath.replace(res, 'FunctionConfiguration.Environment.AccessSysfs',
                              lambda e: val_to_bool(e), inline=False)
        res = keypath.replace(res, 'FunctionConfiguration.Pinned',
                              lambda e: val_to_bool(e), inline=False)
        res = keypath.replace(res, 'FunctionConfiguration.MemorySize',
                              lambda e: int(e), inline=False)
        res = keypath.replace(res, 'FunctionConfiguration.Timeout',
                              lambda e: int(e), inline=False)
        return res

    handler = CollectionHandler(
                    logger, 'Functions', 'FunctionDefinitionId',
                    clean_func,
                    greengrass_client.create_function_definition,
                    greengrass_client.create_function_definition_version,
                    greengrass_client.update_function_definition,
                    greengrass_client.delete_function_definition,
                    greengrass_client.get_function_definition
               )

    crhelper.cfn_handler(event, context,
                         handler.create, handler.update, handler.delete,
                         logger, init_failed)
Exemplo n.º 2
0
def resource_handler(event, context):
    ''' Lambda handler to manage AWS Greengrass ResourceDefinition resources. '''
    global logger
    logger = crhelper.log_config(event)

    def clean_res(resource):
        res = resource
        res = keypath.replace(res,
                              'ResourceDataContainer.LocalDeviceResourceData.GroupOwnerSetting.AutoAddGroupOwner',
                              lambda e: val_to_bool(e),
                              inline=False)
        res = keypath.replace(res,
                              'ResourceDataContainer.LocalVolumeResourceData.GroupOwnerSetting.AutoAddGroupOwner',
                              lambda e: val_to_bool(e),
                              inline=False)
        return res

    handler = CollectionHandler(
                    logger, 'Resources', 'ResourceDefinitionId',
                    clean_res,
                    greengrass_client.create_resource_definition,
                    greengrass_client.create_resource_definition_version,
                    greengrass_client.update_resource_definition,
                    greengrass_client.delete_resource_definition,
                    greengrass_client.get_resource_definition
               )

    crhelper.cfn_handler(event, context,
                         handler.create, handler.update, handler.delete,
                         logger, init_failed)
Exemplo n.º 3
0
def logger_handler(event, context):
    ''' Lambda handler to manage AWS Greengrass LoggerDefinition resources. '''
    global logger
    logger = crhelper.log_config(event)

    def clean_logger(logger_def):
        return keypath.replace(logger_def, 'Space', lambda e: int(e), inline=False)

    handler = CollectionHandler(
                    logger, 'Loggers', 'LoggerDefinitionId',
                    clean_logger,
                    greengrass_client.create_logger_definition,
                    greengrass_client.create_logger_definition_version,
                    greengrass_client.update_logger_definition,
                    greengrass_client.delete_logger_definition,
                    greengrass_client.get_logger_definition
               )

    crhelper.cfn_handler(event, context,
                         handler.create, handler.update, handler.delete,
                         logger, init_failed)
Exemplo n.º 4
0
def core_handler(event, context):
    ''' Lambda handler to manage AWS Greengrass CoreDefinition resources. '''
    global logger
    logger = crhelper.log_config(event)

    def clean_core(core):
        return keypath.replace(core, 'SyncShadow', lambda e: val_to_bool(e), inline=False)

    handler = CollectionHandler(
                    logger, 'Cores', 'CoreDefinitionId',
                    clean_core,
                    greengrass_client.create_core_definition,
                    greengrass_client.create_core_definition_version,
                    greengrass_client.update_core_definition,
                    greengrass_client.delete_core_definition,
                    greengrass_client.get_core_definition
               )

    crhelper.cfn_handler(event, context,
                         handler.create, handler.update, handler.delete,
                         logger, init_failed)
Exemplo n.º 5
0
def subscription_handler(event, context):
    ''' Lambda handler to manage AWS Greengrass SubscriptionDefinition resources. '''
    global logger
    logger = crhelper.log_config(event)

    def clean_sub(subscription):
        return subscription

    handler = CollectionHandler(
                    logger, 'Subscriptions', 'SubscriptionDefinitionId',
                    clean_sub,
                    greengrass_client.create_subscription_definition,
                    greengrass_client.create_subscription_definition_version,
                    greengrass_client.update_subscription_definition,
                    greengrass_client.delete_subscription_definition,
                    greengrass_client.get_subscription_definition
               )

    crhelper.cfn_handler(event, context,
                         handler.create, handler.update, handler.delete,
                         logger, init_failed)
Exemplo n.º 6
0
def handler(event, context):
    # update the logger with event info
    global logger
    logger = crhelper.log_config(event)
    return crhelper.cfn_handler(event, context, create, update, delete, logger,
                                init_failed)
Exemplo n.º 7
0
def lambda_handler(event, context):
    logger.info("<<<<<<<<<< ConfigDeployer Event >>>>>>>>>>")
    logger.info(event)
    logger.debug(context)
    return cfn_handler(event, context, create, update, delete, logger,
                       init_failed)