# vivicorp-aws/cdk-lab-serverless-task-scheduler architecture

> Architecture diagram of the GitHub repository vivicorp-aws/cdk-lab-serverless-task-scheduler, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vivicorp-aws/cdk-lab-serverless-task-scheduler
- Repository: https://github.com/vivicorp-aws/cdk-lab-serverless-task-scheduler

## Overview

##### Main Components

a. Core AWS Services (Primary Layer):
- Amazon EventBridge Scheduler
- AWS Lambda Functions (2 instances)
- Amazon SQS Queue

b. Supporting Services (Secondary Layer):
- AWS CloudWatch (for logging)
- AWS IAM (for roles and permissions)

##### Logging Flow: Both Lambdas → CloudWatch Logs

**┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐**
- EventBridge   │ →   │   Send Task     │ →   │      SQS        │ →   │    Run Task     │
- Scheduler    │     │     Lambda      │     │     Queue       │     │     Lambda      │
- ┘     └─────────────────┘     └─────────────────┘     └─────────────────┘
- ↓                                                ↓
- ┌─────────────────┐                          ┌─────────────────┐
- CloudWatch    │ ← ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │     Logs        │
- ┘                          └─────────────────┘

##### Important Details

- Scheduler Role (invoke Lambda)
- Send Task Lambda Role (SQS send + CloudWatch)
- Run Task Lambda Role (SQS receive + CloudWatch)

- Lambda timeouts (30s for send-task, 1min for run-task)
- SQS configurations (visibility timeout, retention period)
- Scheduler cron/rate expression

##### Additional Elements

b. Timing information:
- Task scheduling patterns
- Queue retention periods
- Lambda execution limits

##### Technical Specifications

- Python runtime version
- Layer dependencies
- Task definition format
- CloudWatch log group structure

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph AWS["AWS Cloud Infrastructure"]
        %% Main Components
        EB["EventBridge Scheduler"]:::eventbridge
        STL["Send Task Lambda"]:::lambda
        SQS["SQS Queue"]:::sqs
        RTL["Run Task Lambda"]:::lambda
        CW["CloudWatch"]:::cloudwatch
        
        %% IAM Roles
        SR["Scheduler IAM Role"]:::iam
        STLR["Send Task IAM Role"]:::iam
        RTLR["Run Task IAM Role"]:::iam
        
        %% Main Flow
        EB -->|Schedule Trigger| STL
        STL -->|Enqueue Task| SQS
        SQS -->|Dequeue Task| RTL
        
        %% IAM Connections
        SR -.->|Permissions| EB
        STLR -.->|Permissions| STL
        RTLR -.->|Permissions| RTL
        
        %% Logging Flow
        STL -->|Logs| CW
        RTL -->|Logs| CW
        
        %% Configuration Notes
        conf["Configuration Parameters<br/>- Lambda Timeouts<br/>- Queue Settings<br/>- Schedule Patterns"]:::note
    end
    
    %% Technical Specifications
    subgraph Specs["Technical Specifications"]
        RT["Runtime: Python"]:::spec
        LD["Lambda Dependencies"]:::spec
        TF["Task Format"]:::spec
    end
    
    %% Legend
    subgraph Legend
        L1["EventBridge"]:::eventbridge
        L2["Lambda Function"]:::lambda
        L3["SQS Queue"]:::sqs
        L4["CloudWatch"]:::cloudwatch
        L5["IAM Role"]:::iam
    end
    
    %% Click Events
    click STL "https://github.com/Vivicorp-AWS/cdk-lab-serverless-task-scheduler/blob/main//lambda/send_task/index.py"
    click RTL "https://github.com/Vivicorp-AWS/cdk-lab-serverless-task-scheduler/blob/main//lambda/run_task/index.py"
    click EB "https://github.com/Vivicorp-AWS/cdk-lab-serverless-task-scheduler/blob/main//stacks/scheduler_stack.py"
    click SQS "https://github.com/Vivicorp-AWS/cdk-lab-serverless-task-scheduler/blob/main//stacks/sqs_stack.py"
    click LD "https://github.com/Vivicorp-AWS/cdk-lab-serverless-task-scheduler/blob/main//requirements-layer.txt"
    
    %% Styles
    classDef eventbridge fill:#FF9900,stroke:#FF9900,color:white
    classDef lambda fill:#1E90FF,stroke:#1E90FF,color:white
    classDef sqs fill:#9932CC,stroke:#9932CC,color:white
    classDef cloudwatch fill:#464646,stroke:#464646,color:white
    classDef iam fill:#FF4500,stroke:#FF4500,color:white
    classDef note fill:#FFFFCC,stroke:#999999
    classDef spec fill:#E6F3FF,stroke:#666666
```
