# froggologies/gcp-terraform-prod-cloud-armor architecture

> Architecture diagram of the GitHub repository froggologies/gcp-terraform-prod-cloud-armor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/froggologies/gcp-terraform-prod-cloud-armor
- Repository: https://github.com/froggologies/gcp-terraform-prod-cloud-armor

## Overview

##### Project Type Analysis
This is a cloud infrastructure security project implementing Web Application Firewall (WAF) rules using Google Cloud Armor, deployed with Terraform. The project focuses on protecting web applications against common vulnerabilities using OWASP ModSecurity Core Rule Set.

##### Main Components

a. External Layer:
- Internet Traffic
- Malicious Users/Attacks
- Legitimate Users

b. Google Cloud Platform Components:
- Cloud Armor Security Policy
- External HTTP(S) Load Balancer
- Instance Group Manager
- Compute Instances (running OWASP Juice Shop)
- VPC Network
- Firewall Rules

**[External Traffic] → [Cloud Armor] → [Load Balancer] → [Instance Group] → [Protected Application]**

##### Specific Elements

a. Security Components:
- Cloud Armor WAF Rules (highlight preconfigured rules)
- Security Policy
- Firewall Rules

b. Network Components:
- VPC Network
- Subnet Configuration
- Load Balancer Components (frontend, backend service)

c. Compute Components:
- Managed Instance Group
- Instance Template
- Service Accounts

##### Important Details to Highlight

a. Security Flow:
- How traffic is filtered through Cloud Armor before reaching the load balancer
- Where WAF rules are applied
- Protected paths and attack vectors

b. Infrastructure Components:
- Relationship between the instance template and instance group
- Auto-scaling capabilities
- Network boundaries

##### Implementation Notes

- Clear hierarchical layout
- Proper grouping of related components
- Export to high-resolution formats

- Overall architecture (architecture.d2)
- Security flow (flow_security_test.d2)
- Infrastructure deployment flow (flow_terraform.d2)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Internet
        Client(("Internet Traffic")):::external
    end

    subgraph Security_Layer
        CA["Cloud Armor WAF"]:::security
        click CA "https://github.com/froggologies/gcp-terraform-prod-cloud-armor/blob/main/compute_security_policy.tf"
        WAF["OWASP ModSecurity Rules"]:::security
        click WAF "https://github.com/froggologies/gcp-terraform-prod-cloud-armor/blob/main/crs_rules.auto.tfvars"
    end

    subgraph Load_Distribution
        LB["Load Balancer"]:::network
        click LB "https://github.com/froggologies/gcp-terraform-prod-cloud-armor/blob/main/load_balancer_components.tf"
        HC["Health Checks"]:::network
    end

    subgraph Compute_Resources
        IGM["Instance Group Manager"]:::compute
        click IGM "https://github.com/froggologies/gcp-terraform-prod-cloud-armor/blob/main/compute_instance_group_manager.tf"
        IT["Instance Template"]:::compute
        click IT "https://github.com/froggologies/gcp-terraform-prod-cloud-armor/blob/main/compute_instance_template.tf"
        VM1["Compute Instance 1"]:::compute
        VM2["Compute Instance 2"]:::compute
    end

    subgraph Network_Layer
        VPC["VPC Network"]:::network
        click VPC "https://github.com/froggologies/gcp-terraform-prod-cloud-armor/blob/main/compute_network.tf"
        FW["Firewall Rules"]:::security
        click FW "https://github.com/froggologies/gcp-terraform-prod-cloud-armor/blob/main/compute_firewall.tf"
    end

    subgraph IAM_Layer
        SA["Service Accounts"]:::iam
        click SA "https://github.com/froggologies/gcp-terraform-prod-cloud-armor/blob/main/service_account.tf"
        IAM["IAM Bindings"]:::iam
        click IAM "https://github.com/froggologies/gcp-terraform-prod-cloud-armor/blob/main/project_iam_member.tf"
    end

    subgraph Project_Config
        PS["Project Setup"]:::config
        click PS "https://github.com/froggologies/gcp-terraform-prod-cloud-armor/blob/main/project.tf"
        OP["Organization Policies"]:::config
        click OP "https://github.com/froggologies/gcp-terraform-prod-cloud-armor/blob/main/project_organization_policy.tf"
        SE["Service Enablement"]:::config
        click SE "https://github.com/froggologies/gcp-terraform-prod-cloud-armor/blob/main/project_service.tf"
    end

    subgraph WAF_Rules
        PA["Protocol Attacks"]:::wafrule
        LFI["LFI Prevention"]:::wafrule
        RCE["RCE Protection"]:::wafrule
        SD["Scanner Detection"]:::wafrule
        SF["Session Fixation"]:::wafrule
    end

    %% Relationships
    Client --> CA
    CA --> WAF
    CA --> LB
    LB --> HC
    HC -.-> VM1
    HC -.-> VM2
    LB --> IGM
    IGM --> VM1
    IGM --> VM2
    IT --> IGM
    VM1 --> VPC
    VM2 --> VPC
    FW --> VPC
    SA --> VM1
    SA --> VM2
    IAM --> SA
    PS --> VPC
    PS --> SA
    OP --> PS
    SE --> PS

    %% WAF Rule Relationships
    WAF --> PA
    WAF --> LFI
    WAF --> RCE
    WAF --> SD
    WAF --> SF

    %% Styling
    classDef external fill:#gray
    classDef security fill:#ff6b6b
    classDef network fill:#4ecdc4
    classDef compute fill:#45b7d1
    classDef iam fill:#ffbe0b
    classDef config fill:#606c38
    classDef wafrule fill:#ff006e

    %% Legend
    subgraph Legend
        L1["External Traffic"]:::external
        L2["Security Component"]:::security
        L3["Network Component"]:::network
        L4["Compute Resource"]:::compute
        L5["IAM Component"]:::iam
        L6["Configuration"]:::config
        L7["WAF Rule"]:::wafrule
    end
```
