"""Lambda index.py function module.""" import json from lambdacommon.common_config import logger from trigger.trigger import run from trigger.utils import LambdaException def handler(event, context): """Lambda entry point. Extracts the params from an SQS message. Args: event (dict): Parameters used to generate the report context (LambdaContext): Context the lambda was run in """ try: if "Records" not in event: raise LambdaException("Params not found. Report could not be triggered.") body = event["Records"][0]["body"] params = json.loads(body) logger.info(params) if "report_run_uuid" not in params: raise LambdaException("Missing report run UUID") return run(report_run_uuid=params["report_run_uuid"]) except Exception as e: logger.exception(str(e)) raise