def lambda_handler()

in functions/backup_dashboard/app.py [0:0]


def lambda_handler(event, context):

    response = cloudwatch.list_dashboards(DashboardNamePrefix="Airflow-")
    logger.info(json.dumps(response, indent=2, default=default))

    for de in response["DashboardEntries"]:

        response = cloudwatch.get_dashboard(DashboardName=de["DashboardName"])

        logger.info(
            f"Backing up {response['DashboardName']} to table {os.environ['DASHBOARD_TEMPLATE_TABLE']}"
        )

        response = table.put_item(
            Item={
                "id": response["DashboardName"],
                "data": response["DashboardBody"],
                "timestamp": datetime.datetime.utcnow().isoformat(),
            }
        )