# mabuwasel/ecs-session architecture

> Architecture diagram of the GitHub repository mabuwasel/ecs-session, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mabuwasel/ecs-session
- Repository: https://github.com/mabuwasel/ecs-session

## Overview

##### Main Components

a. Client-Side Components:
- ECS Session CLI Tool (Main Application)
- AWS CLI (Dependency)
- Session Manager Plugin (Dependency)

b. AWS-Side Components:
- AWS IAM (Authentication/Authorization)
- AWS ECS Service
- AWS ECS Tasks/Containers
- AWS Systems Manager (SSM)

##### Flow Representation

a. Initial authentication flow:
- CLI Tool → AWS IAM (credentials verification)

b. Resource discovery flow:
- CLI Tool → ECS (list clusters)
- CLI Tool → ECS (list services)
- CLI Tool → ECS (list tasks)

c. Session establishment flow:
- CLI Tool → Systems Manager → ECS Container (execute-command)

##### Important Elements to Highlight

- Green: Local components
- Blue: AWS services
- Yellow: Security components (IAM)

- Rectangles: Main components
- Hexagons: AWS services

##### Additional Details

Annotations showing:
- Required IAM permissions (reference iam-policy.json)
- Supported regions
- Execute-command feature requirement

##### Technical Specifications

A small technical requirements section showing:
- Go runtime dependency
- AWS CLI version requirement
- Session Manager Plugin requirement

Key Considerations:
- Keep the focus on the interaction flow between local tools and AWS services
- Authentication and authorization checkpoints
- Execute-command feature as a critical component
- Error handling paths (e.g., when execute-command is not enabled)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef local fill:#90EE90,stroke:#333,stroke-width:2px
    classDef aws fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef security fill:#FFD700,stroke:#333,stroke-width:2px
    classDef plugin fill:#DEB887,stroke:#333,stroke-width:2px

    %% Local Environment Layer
    subgraph Local
        CLI[ECS Session CLI Tool]:::local
        AWSCLI[AWS CLI]:::plugin
        SMP[Session Manager Plugin]:::plugin
    end

    %% AWS Authentication Layer
    subgraph Authentication
        IAM[AWS IAM]:::security
        POLICY[IAM Policies]:::security
    end

    %% AWS Services Layer
    subgraph "AWS Services"
        ECS[AWS ECS Service]:::aws
        SSM[Systems Manager]:::aws
        subgraph "ECS Resources"
            CLUSTERS[ECS Clusters]:::aws
            SERVICES[ECS Services]:::aws
            TASKS[ECS Tasks/Containers]:::aws
        end
    end

    %% Connections
    CLI --> AWSCLI
    CLI --> SMP
    CLI --> IAM
    IAM --> POLICY
    CLI --> ECS
    ECS --> CLUSTERS
    CLUSTERS --> SERVICES
    SERVICES --> TASKS
    CLI --> SSM
    SSM --> TASKS

    %% Technical Requirements
    subgraph "Technical Requirements"
        GO[Go Runtime]
        CLIPREQ[AWS CLI v2+]
        SMPREQ[Session Manager Plugin]
    end

    %% Click events for component mapping
    click CLI "https://github.com/mabuwasel/ecs-session/blob/main/main.go"
    click POLICY "https://github.com/mabuwasel/ecs-session/blob/main/iam-policy.json"
    click GO "https://github.com/mabuwasel/ecs-session/blob/main/go.mod"
    click CLIPREQ "https://github.com/mabuwasel/ecs-session/blob/main/README.md"

    %% Legend
    subgraph Legend
        L1[Local Components]:::local
        L2[AWS Services]:::aws
        L3[Security Components]:::security
        L4[Plugin Components]:::plugin
    end
```
