def process_dashboard_actions()

in apps/cloudwatch-dashboard/lambdas/list-schedulers/handler.py [0:0]


def process_dashboard_actions(event):
    """
    Creates a dedicated dashboard for a scheduler, create and start a new
    CloudWatch Synthetics Canary to send a dashboard screenshot every Monday
    morning.
    """
    dashboard_name = event['dashboard_name']
    scheduler_name = event['scheduler_name']
    action = event['action']
    
    if action == 'create_dashboard':
        dashboard_body = {
           "start": "-P3M",
           "periodOverride": "inherit",
           "widgets": [{
                "x": 12, "y": 0, "height": 8, "width": 12,
                "type": "custom",
                "properties": {
                    "endpoint": f"arn:aws:lambda:{current_region}:{account_id}:function:l4e-dashboard-scheduler-details{stack}",
                    "updateOn": {
                        "refresh": True,
                        "resize": True,
                        "timeRange": False
                    },
                    "params": {
                        "scheduler_name": scheduler_name
                    },
                    "title": f"{scheduler_name} | Inference scheduler details"
                }
            },
            {
                "x": 0, "y": 0, "height": 8, "width": 12,
                "type": "custom",
                "properties": {
                    "endpoint": f"arn:aws:lambda:{current_region}:{account_id}:function:l4e-dashboard-scheduler-last-execution-details{stack}",
                    "updateOn": {
                        "refresh": True,
                        "resize": True,
                        "timeRange": True
                    },
                    "params": {
                        "scheduler_name": scheduler_name
                    },
                    "title": f"{scheduler_name} | Last execution diagnostics"
                }
            }
            ]
        }

        cw_client.put_dashboard(
            DashboardName=dashboard_name,
            DashboardBody=json.dumps(dashboard_body)
        )
        
        create_synthetics(dashboard_name)