def put_function()

in functions/source/registerCustomResource/lambda_function.py [0:0]


def put_function(function_name, execution_role, zip_uri):
    try:
        arn = lmbd.get_function_configuration(FunctionName=function_name)['FunctionArn']
        exists = True
    except lmbd.exceptions.ResourceNotFoundException:
        exists = False
    kwargs = {
        'FunctionName': function_name,
        'Role': execution_role,
        'Handler': 'lambda_function.lambda_handler',
        'Timeout': 900,
        'MemorySize': 1024,
        'Runtime': 'python3.8'
    }
    if not exists:
        kwargs['Code'] = {
            'S3Bucket': zip_uri.split('/')[2],
            'S3Key': '/'.join('s3://bucket/keyprefix/mid/filename.ext'.split('/')[3:])
        }
        return lmbd.create_function(**kwargs)['FunctionArn']
    else:
        lmbd.update_function_code(
            FunctionName=function_name,
            S3Bucket=zip_uri.split('/')[2],
            S3Key='/'.join('s3://bucket/keyprefix/mid/filename.ext'.split('/')[3:])
        )
        lmbd.update_function_configuration(**kwargs)