def lambda_handler()

in source/lib/s3_to_efs/s3_to_efs.py [0:0]


def lambda_handler(event, context):
    try:
        request_type = event['RequestType'].upper() if ('RequestType' in event) else ""
        # fix for update
        if 'CREATE' in request_type or 'UPDATE' in request_type:
            path = event['ResourceProperties']['MountPath']

            for url in event['ResourceProperties']['Objects']:
                download_file(url, path)

            result = {
                'StatusCode': '200',
                'Body': {'message': 'success'}
            }
            return json.dumps(result)
        elif 'DELETE' in request_type:
            resourceId = event['PhysicalResourceId'] if 'PhysicalResourceId' in event else event['LogicalResourceId']

    except Exception as e:
        print("EXCEPTION", e)
        resourceId = event['PhysicalResourceId'] if 'PhysicalResourceId' in event else event['LogicalResourceId']
        send_response(event, context, 'FAILED', resourceId, e)