def handler()

in lambda_run_redshift_script.py [0:0]


def handler(event, context):
    print(event)
    action = event['input'].get('Action')
    redshift_host = event['input'].get('RedshiftHost')
    redshift_db = event['input'].get('RedshiftDb')
    redshift_user = event['input'].get('RedshiftUser')
    redshift_iam_role = event['input'].get('RedshiftIamRole')
    script_s3_path = event['input'].get('ScriptS3Path')
    sql_query_id = event['input'].get('sql_query_id')

    try:
        if action == "RUN_REDSHIFT_SCRIPT":
            res = {'sql_id': run_sql(redshift_host, redshift_db, redshift_user, redshift_iam_role, script_s3_path)}
        elif action == "SQL_STATUS":
            res = {'status': sql_status(sql_query_id)}
        else:
            raise ValueError("Invalid Task: " + action)
    except Exception as e:
        print(e)
        print(traceback.format_exc())
        raise
    print(res)
    return res