# cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation architecture

> Architecture diagram of the GitHub repository cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation
- Repository: https://github.com/cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation

## Overview

##### Project type and purpose
- This is an AWS-native, event-driven, open-source solution (“AWS Security Hub Automated Response and Remediation”) written in TypeScript and Python, using the AWS CDK to generate CloudFormation templates.
- Purpose: automatically remediate AWS Security Hub findings by mapping incoming findings to “playbooks” (SSM Automation runbooks) and shared remediation runbooks.

##### File structure
- Top-level “source” directory breaks into:
- LambdaLayers (reusable Python code loaded as Lambda layers)
- Orchestrator (Step Functions + Lambdas that receive Security Hub events and dispatch playbooks)
- playbooks (CDK TS code + Lambda/SSM runbook assets for each standard: AFSBP, CIS120, PCI321, and user-defined NEWPLAYBOOK)
- remediation_runbooks (shared SSM Automation documents + Python helper scripts)
- solution_deploy (CDK TS code for the SolutionDeployStack that wires everything and defines member stacks, log stacks, remediation runbook stacks)
- deployment (build scripts, unit-test runners)
- Configuration/build files: package.json, tsconfig.json, jest.config.js, buildspec.yml.

##### Key insights from the README
- EventBridge rules trigger remediation workflow.
- Orchestrator is a Step Functions state machine with several Python Lambdas from LambdaLayers.
- Each playbook package is a CDK construct that bundles: a TS “bin” entrypoint, test suite, SSM runbook YAMLs under ssmdocs, and parsing scripts.
- Remediation runbooks and IAM roles are created by the remediation_runbooks construct.
- Deployment uses two S3 buckets (global & regional), build-and-upload scripts, and solution_deploy CDK.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% AWS Services
    SECURITYHUB["AWS Security Hub"]:::aws
    EVENTBRIDGE["Amazon EventBridge"]:::aws
    STEPFUNC["AWS Step Functions"]:::aws
    LAMBDA_DISPATCH["Lambda: check_ssm_doc_state,\nexec_ssm_doc"]:::aws
    SSM["AWS Systems Manager Automation"]:::aws
    CLOUDWATCH["Amazon CloudWatch\n(Logs & Metrics)"]:::aws
    CFN["AWS CloudFormation"]:::aws
    S3_ARTIFACT["Amazon S3\n(Code & Templates)"]:::aws_dashed

    %% CDK Constructs
    subgraph "Infrastructure (CDK Constructs)" 
        ORCH_STACK["OrchestratorStack"]:::cdk
        PLAYBOOKS["PlaybookStacks\n(AFSBP, CIS120, PCI321, NEWPLAYBOOK)"]:::cdk
        REM_RUNBOOK_STACK["RemediationRunbookStack"]:::cdk
        SOLDEPLOY_STACK["SolutionDeployStack"]:::cdk
    end

    %% Code Artifacts
    subgraph "Source Code & Assets"
        LAMBDA_LAYERS["LambdaLayers"]:::code
        ORCHESTRATOR_CODE["Orchestrator Code"]:::code
        ORCH_CDK_COMMON["orchestrator_roles-construct.ts\ncommon-orchestrator-construct.ts"]:::code
        PLAYBOOK_AFSBP["Playbook AFSBP"]:::code
        PLAYBOOK_CIS["Playbook CIS120"]:::code
        PLAYBOOK_PCI["Playbook PCI321"]:::code
        PLAYBOOK_NEW["Playbook NEWPLAYBOOK"]:::code
        PLAYBOOK_COMMON["Playbook Common Parsing Library"]:::code
        REMED_RUNBOOKS["Shared Remediation Runbooks"]:::code
        REMED_HELPER["rds6-remediation-resources.ts"]:::code
        SOLDEPLOY_CODE["solution_deploy Code"]:::code
        SOLDEP_ORCH_LOG["orchestrator-log-stack.ts"]:::code
        SOLDEP_REM_STACK["remediation_runbook-stack.ts"]:::code
        SOLDEP_MEMBER["sharr_member-stack.ts"]:::code
        SOLDEP_MAIN["solution_deploy-stack.ts"]:::code
        RUNBOOK_FACTORY["runbook_factory.ts"]:::code
        DEPLOY_SCRIPTS["Deployment Scripts"]:::code
        ROOT_CONFIG["tsconfig.json\npackage.json\njest.config.js"]:::code
    end

    %% Flow of Events
    SECURITYHUB -->|Findings| EVENTBRIDGE
    EVENTBRIDGE -->|invoke| STEPFUNC
    STEPFUNC -->|executes| LAMBDA_DISPATCH
    LAMBDA_DISPATCH -->|StartAutomationExecution| SSM
    SSM -->|invokes remediation| REMED_RUNBOOKS
    REMED_RUNBOOKS -->|API calls| CLOUDWATCH
    STEPFUNC -->|logs metrics| CLOUDWATCH

    %% Deployment Pipeline
    DEPLOY_SCRIPTS -->|build & upload| S3_ARTIFACT
    S3_ARTIFACT -->|artifacts| SOLDEPLOY_STACK
    SOLDEPLOY_STACK -->|deploys via| CFN
    CFN -->|provisions| ORCH_STACK
    CFN -->|provisions| PLAYBOOKS
    CFN -->|provisions| REM_RUNBOOK_STACK

    %% CDK to Code Relationships
    ORCH_STACK --> ORCHESTRATOR_CODE
    ORCHESTRATOR_CODE --> ORCH_CDK_COMMON
    PLAYBOOKS --> PLAYBOOK_AFSBP
    PLAYBOOKS --> PLAYBOOK_CIS
    PLAYBOOKS --> PLAYBOOK_PCI
    PLAYBOOKS --> PLAYBOOK_NEW
    PLAYBOOK_AFSBP --> PLAYBOOK_COMMON
    PLAYBOOK_CIS --> PLAYBOOK_COMMON
    PLAYBOOK_PCI --> PLAYBOOK_COMMON
    PLAYBOOK_NEW --> PLAYBOOK_COMMON
    REM_RUNBOOK_STACK --> REMED_RUNBOOKS
    REM_RUNBOOK_STACK --> REMED_HELPER
    SOLDEPLOY_STACK --> SOLDEPLOY_CODE
    SOLDEPLOY_CODE --> SOLDEP_ORCH_LOG
    SOLDEPLOY_CODE --> SOLDEP_REM_STACK
    SOLDEPLOY_CODE --> SOLDEP_MEMBER
    SOLDEPLOY_CODE --> SOLDEP_MAIN
    SOLDEPLOY_CODE --> RUNBOOK_FACTORY

    %% Click Events
    click LAMBDA_LAYERS "https://github.com/cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation/tree/main/source/LambdaLayers/"
    click ORCHESTRATOR_CODE "https://github.com/cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation/tree/main/source/Orchestrator/"
    click ORCH_CDK_COMMON "https://github.com/cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation/blob/main/source/lib/orchestrator_roles-construct.ts"
    click ORCH_CDK_COMMON "https://github.com/cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation/blob/main/source/Orchestrator/lib/common-orchestrator-construct.ts"
    click PLAYBOOK_AFSBP "https://github.com/cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation/tree/main/source/playbooks/AFSBP/"
    click PLAYBOOK_CIS "https://github.com/cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation/tree/main/source/playbooks/CIS120/"
    click PLAYBOOK_PCI "https://github.com/cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation/tree/main/source/playbooks/PCI321/"
    click PLAYBOOK_NEW "https://github.com/cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation/tree/main/source/playbooks/NEWPLAYBOOK/"
    click PLAYBOOK_COMMON "https://github.com/cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation/tree/main/source/playbooks/common/"
    click REMED_RUNBOOKS "https://github.com/cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation/tree/main/source/remediation_runbooks/"
    click REMED_HELPER "https://github.com/cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation/blob/main/source/remediation_runbooks/rds6-remediation-resources.ts"
    click SOLDEPLOY_CODE "https://github.com/cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation/tree/main/source/solution_deploy/"
    click SOLDEP_ORCH_LOG "https://github.com/cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation/blob/main/source/solution_deploy/lib/orchestrator-log-stack.ts"
    click SOLDEP_REM_STACK "https://github.com/cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation/blob/main/source/solution_deploy/lib/remediation_runbook-stack.ts"
    click SOLDEP_MEMBER "https://github.com/cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation/blob/main/source/solution_deploy/lib/sharr_member-stack.ts"
    click SOLDEP_MAIN "https://github.com/cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation/blob/main/source/solution_deploy/lib/solution_deploy-stack.ts"
    click RUNBOOK_FACTORY "https://github.com/cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation/blob/main/source/solution_deploy/lib/runbook_factory.ts"
    click DEPLOY_SCRIPTS "https://github.com/cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation/tree/main/deployment/"
    click ROOT_CONFIG "https://github.com/cm-kajiwara-taishi/aws-security-hub-automated-response-and-remediation/blob/main/source/tsconfig.json"

    %% Styles
    classDef aws fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef aws_dashed fill:#ADD8E6,stroke:#000,stroke-width:1px,stroke-dasharray: 5 5
    classDef cdk fill:#90EE90,stroke:#000,stroke-width:1px
    classDef code fill:#FFFACD,stroke:#000,stroke-width:1px
```
