# aws-devops-projects/devops-projects architecture

> Architecture diagram of the GitHub repository aws-devops-projects/devops-projects, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aws-devops-projects/devops-projects
- Repository: https://github.com/aws-devops-projects/devops-projects

## Overview

##### Main Components
- CI/CD Infrastructure: Represented by the Jenkins project. Clearly show two roles – the Jenkins controller and Jenkins agent. Indicate that the Jenkins setup uses Ansible roles (e.g., tasks for Java, SSH, and tools) and Terraform modules (for EC2, EFS, IAM, and LB-ASG) to provision and configure infrastructure.
- Service Discovery & Load Balancing: From the Consul service discovery project. Include components for the Consul server configurations, backends (using Ansible roles for consul, backends, and load-balancer), and associated templates. Also note the use of Terraform for provisioning related parts.
- Application Deployment: The scalable Java application project, highlighted by the Jenkinsfile and supporting Ansible roles for Java deployment, cloudwatch integration, and node_exporter provisioning. Also include Terraform modules for load balancer and RDS resources that support this application.
- Infrastructure & Environment Setup: Include the dev-vms folder (with a Vagrantfile for Ubuntu-22) and the generic-scripts folder (which also uses Terraform to provision EC2 instances). These represent the foundational VM and infrastructure automation that underpin the CI/CD and application environments.

##### Relationships and Interactions
- That the Jenkins Controller orchestrates the CI/CD pipeline and communicates with Jenkins Agents to run jobs that build, test, and deploy the scalable Java application.
- That both Jenkins and the application deployments leverage Ansible for configuration management and environment consistency.
- How Terraform modules wrap around various infrastructure aspects (like EC2, IAM, EFS, and LB-ASG) and that these modules are common components, accessed by both the Jenkins setup and the scalable Java app. This creates a dependency between the CI/CD pipeline and the underlying infrastructure provisioning.
- For Consul service discovery, clearly show how the Consul servers interact with the load balancer and backends. This section is integral for enabling dynamic service registration and discovery in a microservices or distributed environment.

##### Architectural Patterns and Design Principles
- Modularization: The use of Ansible roles (for Jenkins components, Consul servers, and Java deployment tasks) and Terraform modules (for EC2, EFS, IAM, LB-ASG, and RDS) ensures a modular, reusable design.
- Infrastructure as Code (IaC): Terraform and Packer components denote the IaC approach, making the infrastructure reproducible and version-controlled.
- Automation and Orchestration: Jenkins as the orchestrator for CI/CD pipelines, seamlessly linking code changes to deployment tasks.
- Service Discovery and Scalability: The inclusion of Consul and load balancer configurations shows that the system is designed with dynamic service mapping and scalability in mind.

##### Relevant Technologies and Tools
- Ansible: For configuration management across Jenkins, Consul, and the scalable Java app.
- Terraform: For provisioning infrastructure resources (EC2, EFS, IAM, LB-ASG, RDS, etc.).
- Packer: For building AMIs for Jenkins agents/controllers.
- Vagrant: For local VM environment setup (dev-vms folder).
- Jenkins: As the primary CI/CD tool, with clearly defined roles (controller and agents).
- Consul: For service discovery.
- Java: As the core technology for the scalable application, with accompanying supporting tools (e.g., node_exporter, Python tasks).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "CI/CD Infrastructure"
        A["Jenkins Controller"]:::cicd
        B["Jenkins Agent"]:::cicd
        C["Terraform Modules (Jenkins)"]:::cicd
    end

    subgraph "Service Discovery & Load Balancer"
        D["Consul Server"]:::consul
        E["Consul Backends"]:::consul
        F["Load Balancer (Consul)"]:::consul
        G["Terraform (Consul)"]:::consul
    end

    subgraph "Application Deployment"
        H["CI/CD Pipeline (Jenkinsfile)"]:::app
        I["App Deployment (Ansible-Java)"]:::app
        J["Terraform Modules (App LB-ASG)"]:::app
        K["Terraform Modules (App RDS)"]:::app
    end

    subgraph "Infrastructure & Environment Setup"
        L["Dev VMs (Vagrant Ubuntu-22)"]:::infra
        M["Generic Infrastructure Scripts"]:::infra
    end

    %% CI/CD Infrastructure interactions
    A -->|"triggers"| B
    A -->|"provisions"| C

    %% Pipeline orchestrations
    H -->|"orchestrates"| A
    H -->|"orchestrates"| B
    H -->|"triggers"| I

    %% Shared Terraform modules usage
    C -->|"sharedModule"| J
    C -->|"sharedModule"| K

    %% App Deployment provisioning
    I -->|"provisionsLB"| J
    I -->|"provisionsRDS"| K

    %% Service Discovery interactions
    D -->|"updates"| E
    E -->|"routes"| F
    F -->|"provisions"| G

    %% Infrastructure support for provisioning
    L -->|"supports"| C
    M -->|"supports"| C

    %% Class definitions for colors
    classDef cicd fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef consul fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef app fill:#FFD700,stroke:#000,stroke-width:1px;
    classDef infra fill:#D3D3D3,stroke:#000,stroke-width:1px;

    %% Click Events
    click A "https://github.com/aws-devops-projects/devops-projects/tree/main/01-jenkins-setup/ansible/roles/jenkins-controller"
    click B "https://github.com/aws-devops-projects/devops-projects/tree/main/01-jenkins-setup/ansible/roles/jenkins-agent"
    click C "https://github.com/aws-devops-projects/devops-projects/tree/main/01-jenkins-setup/terraform/modules"
    click D "https://github.com/aws-devops-projects/devops-projects/tree/main/02-consul-sevice-discovery/ansible/roles/consul"
    click E "https://github.com/aws-devops-projects/devops-projects/tree/main/02-consul-sevice-discovery/ansible/roles/backends"
    click F "https://github.com/aws-devops-projects/devops-projects/tree/main/02-consul-sevice-discovery/ansible/roles/load-balancer"
    click G "https://github.com/aws-devops-projects/devops-projects/tree/main/02-consul-sevice-discovery/terraform"
    click H "https://github.com/aws-devops-projects/devops-projects/tree/main/03-scalable-java-app/Jenkinsfile"
    click I "https://github.com/aws-devops-projects/devops-projects/tree/main/03-scalable-java-app/ansible/roles/java"
    click J "https://github.com/aws-devops-projects/devops-projects/tree/main/03-scalable-java-app/terraform/modules"
    click K "https://github.com/aws-devops-projects/devops-projects/tree/main/03-scalable-java-app/terraform/rds"
    click L "https://github.com/aws-devops-projects/devops-projects/tree/main/dev-vms/ubuntu-22/Vagrantfile"
    click M "https://github.com/aws-devops-projects/devops-projects/blob/main/generic-scripts/terraform/ec2/instance.tf"
```
