def get_environment_variables()

in source/lambdafunctions/lambdaedge/lambda_function.py [0:0]


def get_environment_variables(request):
    global DEBUG
    global CAPTION_PASSTHROUGH
    global CAPTION_REPLACE
    global CAPTION_BUFFER
    global DYNAMO_INDEX
    global DYNAMO_TABLE
    global CLOUDWATCH_NAMESPACE
    global PIPE_ID

    try:
        ## Optional Variables - Debugging / Metrics
        if 'cf5k-debug' in request:
            DEBUG = str_to_bool(request['cf5k-debug'][0]['value'])
            if DEBUG: 
                print('DEBUG GLOBAL customHeader DEBUG: {}'.format(DEBUG))
        if DEBUG:
            print('DEBUG raw list of customHeader: {}'.format(request))

        ## Optional Variables - Features
        # CAPTION_PASSTHROUGH
        if 'caption_passthrough' in request:
            CAPTION_PASSTHROUGH = str_to_bool(request['caption_passthrough'][0]['value'])
            if DEBUG: 
                print('DEBUG GLOBAL customHeader CAPTION_PASSTHROUGH: {}'.format(CAPTION_PASSTHROUGH))
        # CAPTION_REPLACE
        if 'caption_replace' in request:
            CAPTION_REPLACE = str_to_bool(request['caption_replace'][0]['value'])
            if DEBUG: 
                print('DEBUG GLOBAL customHeader CAPTION_REPLACE: {}'.format(CAPTION_REPLACE))
        # CAPTION_BUFFER
        if 'caption_buffer' in request:
            CAPTION_BUFFER = str_to_bool(request['caption_buffer'][0]['value'])
            if DEBUG: 
                print('DEBUG GLOBAL customHeader CAPTION_BUFFER: {}'.format(CAPTION_BUFFER))
        # CLOUDWATCH_NAMESPACE
        if 'cloudwatch_namespace' in request:
            CLOUDWATCH_NAMESPACE = request['cloudwatch_namespace'][0]['value']
            if DEBUG: 
                print('DEBUG GLOBAL customHeader CLOUDWATCH_NAMESPACE: {}'.format(CLOUDWATCH_NAMESPACE))

        ## Mandatory Variables - DynamoDB configuration
        # DYNAMO_INDEX
        if 'dynamo_index' in request:
            DYNAMO_INDEX = request['dynamo_index'][0]['value']
            if DEBUG: 
                print('DEBUG GLOBAL customHeader DYNAMO_INDEX: {}'.format(DYNAMO_INDEX))
        else:
            print("ERROR GLOBAL customHeader DYNAMO_INDEX NOT FOUND!")
            return False
        # DYNAMO_TABLE
        if 'dynamo_table' in request:
            DYNAMO_TABLE = request['dynamo_table'][0]['value']
            if DEBUG: 
                print('DEBUG GLOBAL customHeader DYNAMO_TABLE: {}'.format(DYNAMO_TABLE))
        else:
            print("ERROR GLOBAL customHeader DYNAMO_TABLE NOT FOUND!")
            return False
        # PIPE
        if 'pipe_id' in request:
            PIPE_ID = request['pipe_id'][0]['value']
            if DEBUG: 
                print('DEBUG GLOBAL customHeader PIPE_ID: {}'.format(PIPE_ID))
        else:
            print("ERROR GLOBAL customHeader PIPE_ID NOT FOUND!")
            return False
    except: 
        print("ERROR get_environment_variables Exception")
        print_exception()
        return False

    return True