# ramyadav08/ecs-blue-green-deployement-with-terraform architecture

> Architecture diagram of the GitHub repository ramyadav08/ecs-blue-green-deployement-with-terraform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ramyadav08/ecs-blue-green-deployement-with-terraform
- Repository: https://github.com/ramyadav08/ecs-blue-green-deployement-with-terraform

## Overview

##### Project type and purpose
- This is an infrastructure-as-code project for provisioning and managing a Blue/Green deployment pipeline of a containerized Python web app on AWS ECS, using Terraform modules.
- The small “app” folder contains a Flask application (app.py) and Dockerfile; Terraform code in the root and modules sets up networking, IAM, ECR, ECS, CodeDeploy, CloudWatch Logs, Auto Scaling, and an Application Load Balancer (ALB) to perform blue/green rollouts.

##### File structure
- Top-level:
- main.tf, variables.tf, provider.tf, terraform.tfvars: root Terraform orchestrator
- modules/: reusable Terraform modules for each AWS component (VPC, SG, IAM, ECR, ECS, ASG, ALB, CodeDeploy, CloudWatch Logs)
- app/: containerized Flask app and its requirements
- .github/workflows/: two CI workflows—one to deploy infra (“infra.yaml”), one to build/apply code updates (“app-deploy.yaml”)
- Patterns: modular design for each AWS resource; clear separation of application code (in app/) from infrastructure code.

##### README
- Title “Ecs-Blue-green-deployement-with-terraform” confirms blue/green deployment focus.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% CI/CD Layer
    subgraph "CI/CD Pipelines"
        direction TB
        InfraWorkflow["Infra Workflow"]:::cd
        AppWorkflow["App Deploy Workflow"]:::cd
    end

    %% Terraform Root
    TerraformRoot["Root Terraform Orchestrator"]:::tf

    %% Terraform Modules
    subgraph "Terraform Modules"
        direction TB
        VPCMod["VPC Module"]:::module
        SGMod["Security Groups Module"]:::module
        IAMMod["IAM Roles & Policies Module"]:::module
        ECRMod["ECR Repository Module"]:::module
        ECSMod["ECS Cluster & Service Module"]:::module
        ASGMod["Auto Scaling Group Module"]:::module
        ALBMod["Application Load Balancer Module"]:::module
        CDMod["CodeDeploy Blue/Green Module"]:::module
        CWMod["CloudWatch Logs Module"]:::module
    end

    %% Application Build
    DockerBuild["Docker Build & Push"]:::app

    %% AWS Infrastructure Boundary
    subgraph "VPC (private & public subnets)"
        direction TB
        SGNode["Security Groups"]:::aws
        subgraph "Compute Layer"
            direction TB
            ASGNode["Auto Scaling Group"]:::aws
            ECSCluster["ECS Cluster"]:::aws
            ECSService["ECS Service"]:::aws
            subgraph "Blue/Green Task Sets"
                direction TB
                ECSBlue["Blue Task Set"]:::blue
                ECSGreen["Green Task Set"]:::green
            end
        end
        ALBNode["Application Load Balancer"]:::aws
    end

    CloudWatch["CloudWatch Logs"]:::aws

    %% Connections
    InfraWorkflow --> TerraformRoot
    TerraformRoot --> VPCMod
    TerraformRoot --> SGMod
    TerraformRoot --> IAMMod
    TerraformRoot --> ECRMod
    TerraformRoot --> ECSMod
    TerraformRoot --> ASGMod
    TerraformRoot --> ALBMod
    TerraformRoot --> CDMod
    TerraformRoot --> CWMod

    AppWorkflow --> DockerBuild
    DockerBuild --> ECRNode["ECR Repository"]:::aws
    ECRNode --> CDNode["CodeDeploy Service"]:::aws
    CDNode --> ECSBlue
    CDNode --> ECSGreen

    ASGMod --> ASGNode
    ASGNode --> ECSCluster
    ECSMod --> ECSService
    ECSService --> ECSBlue
    ECSService --> ECSGreen

    ALBNode -->|"primary target"| ECSBlue
    ALBNode -->|"test target"| ECSGreen

    ECSBlue --> CloudWatch
    ECSGreen --> CloudWatch

    SGMod --> SGNode
    IAMMod --> SGNode
    IAMMod --> ASGNode
    IAMMod --> ECSService
    IAMMod --> CDNode

    %% Click events
    click InfraWorkflow "https://github.com/ramyadav08/ecs-blue-green-deployement-with-terraform/blob/main/.github/workflows/infra.yaml"
    click AppWorkflow "https://github.com/ramyadav08/ecs-blue-green-deployement-with-terraform/blob/main/.github/workflows/app-depoy.yaml"
    click TerraformRoot "https://github.com/ramyadav08/ecs-blue-green-deployement-with-terraform/blob/main/main.tf"
    click VPCMod "https://github.com/ramyadav08/ecs-blue-green-deployement-with-terraform/blob/main/modules/VPC/main.tf"
    click SGMod "https://github.com/ramyadav08/ecs-blue-green-deployement-with-terraform/blob/main/modules/SG/main.tf"
    click IAMMod "https://github.com/ramyadav08/ecs-blue-green-deployement-with-terraform/blob/main/modules/IAM/main.tf"
    click ECRMod "https://github.com/ramyadav08/ecs-blue-green-deployement-with-terraform/blob/main/modules/ECR/main.tf"
    click ECSMod "https://github.com/ramyadav08/ecs-blue-green-deployement-with-terraform/blob/main/modules/ECS/main.tf"
    click ASGMod "https://github.com/ramyadav08/ecs-blue-green-deployement-with-terraform/blob/main/modules/ASG/main.tf"
    click ALBMod "https://github.com/ramyadav08/ecs-blue-green-deployement-with-terraform/blob/main/modules/ALB/main.tf"
    click CDMod "https://github.com/ramyadav08/ecs-blue-green-deployement-with-terraform/blob/main/modules/CODE-DEPLOY/main.tf"
    click CWMod "https://github.com/ramyadav08/ecs-blue-green-deployement-with-terraform/blob/main/modules/CLOUDWATCHLOG/main.tf"

    %% Styles
    classDef cd fill:#f3e5f5,stroke:#7e57c2,stroke-width:1px
    classDef tf fill:#bbdefb,stroke:#1e88e5,stroke-width:1px
    classDef module fill:#e0f7fa,stroke:#00838f,stroke-width:1px
    classDef app fill:#c8e6c9,stroke:#2e7d32,stroke-width:1px
    classDef aws fill:#bbdefb,stroke:#1565c0,stroke-width:1px
    classDef blue fill:#a5d6a7,stroke:#388e3c,stroke-width:1px
    classDef green fill:#ffe0b2,stroke:#f57c00,stroke-width:1px
```
