# mrjoy/terraform-cidr-subnets architecture

> Architecture diagram of the GitHub repository mrjoy/terraform-cidr-subnets, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mrjoy/terraform-cidr-subnets
- Repository: https://github.com/mrjoy/terraform-cidr-subnets

## Overview

##### Core Components

a. Input Processing Layer
- Module's input parameters:
- base_cidr_block (primary input)
- networks list (containing name and new_bits)

b. Processing Layer
- CIDR Calculator Component
- Core logic that performs subnet calculations
- Sequential allocation of address spaces
- Network Validation Component
- Represents the validation of network configurations

c. Output Layer
- Two primary outputs:
- network_cidr_blocks (map output)
- networks (list output)

##### Integration Points

a. Cloud Provider Integration
- Supported cloud providers:
- AWS
- Azure
- GCP
- AliCloud
- As external systems (clouds)

##### Data Flow

- Input parameters → Processing Layer
- Processing Layer → Output Layer
- Output Layer → Cloud Provider Integration

##### Additional Elements

b. A version compatibility note:
- Terraform v0.12.10+ requirement

##### Technical Notes

Annotations explaining:
- CIDR calculation logic
- Network address space allocation strategy
- Backward compatibility considerations
- CSV input support

Remember to emphasize that this is a stateless calculation module, not a stateful infrastructure provisioning system, which is an important distinction for understanding its architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Title
    title[("Terraform CIDR Subnets<br/>Module Architecture")]:::title

    %% Input Layer
    subgraph InputLayer["Input Processing Layer"]
        input_params["Input Parameters"]:::input
        base_cidr["Base CIDR Block"]:::input
        networks_list["Networks List<br/>(name + new_bits)"]:::input
    end
    click input_params "https://github.com/MrJoy/terraform-cidr-subnets/blob/master/variables.tf"

    %% Version Requirements
    version_req["Version Requirements<br/>Terraform v0.12.10+"]:::version
    click version_req "https://github.com/MrJoy/terraform-cidr-subnets/blob/master/versions.tf"

    %% Processing Layer
    subgraph ProcessingLayer["Core Processing Layer"]
        cidr_calc["CIDR Calculator<br/>Component"]:::processing
        network_valid["Network Validation<br/>Component"]:::processing
        state_mgmt["State Management"]:::processing
    end
    click ProcessingLayer "https://github.com/MrJoy/terraform-cidr-subnets/blob/master/main.tf"

    %% Testing Components
    subgraph TestingLayer["Testing Components"]
        basic_test["Basic Testing"]:::testing
        ipv6_test["IPv6 Testing"]:::testing
        null_test["Null Handling Test"]:::testing
        ipv6_null_test["IPv6 Null Handling Test"]:::testing
    end
    click basic_test "https://github.com/MrJoy/terraform-cidr-subnets/blob/master/test/simple.tf"
    click ipv6_test "https://github.com/MrJoy/terraform-cidr-subnets/blob/master/test/simple_ipv6.tf"
    click null_test "https://github.com/MrJoy/terraform-cidr-subnets/blob/master/test/null_name.tf"
    click ipv6_null_test "https://github.com/MrJoy/terraform-cidr-subnets/blob/master/test/null_name_ipv6.tf"

    %% Output Layer
    subgraph OutputLayer["Output Processing Layer"]
        network_cidr[/"Network CIDR Blocks<br/>(Map Output)"/]:::output
        networks_output[/"Networks List<br/>Output"/]:::output
    end
    click OutputLayer "https://github.com/MrJoy/terraform-cidr-subnets/blob/master/outputs.tf"

    %% Cloud Providers
    subgraph CloudProviders["Cloud Providers"]
        aws["AWS"]:::cloud
        azure["Azure"]:::cloud
        gcp["GCP"]:::cloud
        alicloud["AliCloud"]:::cloud
    end

    %% Connections
    input_params --> cidr_calc
    base_cidr --> cidr_calc
    networks_list --> cidr_calc
    version_req -.-> cidr_calc
    cidr_calc --> network_valid
    network_valid --> state_mgmt
    state_mgmt --> network_cidr
    state_mgmt --> networks_output
    network_cidr -.-> aws & azure & gcp & alicloud
    networks_output -.-> aws & azure & gcp & alicloud

    %% Testing Connections
    cidr_calc -.-> basic_test & ipv6_test
    state_mgmt -.-> null_test & ipv6_null_test

    %% Styles
    classDef title fill:#f9f,stroke:#333,stroke-width:4px
    classDef input fill:#b3e0ff,stroke:#333
    classDef processing fill:#98FB98,stroke:#333
    classDef output fill:#FFE5B4,stroke:#333
    classDef cloud fill:#E6E6FA,stroke:#333,stroke-dasharray: 5 5
    classDef version fill:#F0F8FF,stroke:#333
    classDef testing fill:#FFC0CB,stroke:#333

    %% Legend
    subgraph Legend
        l1["Input Component"]:::input
        l2["Processing Component"]:::processing
        l3[/"Output Component"/]:::output
        l4["Cloud Provider"]:::cloud
        l5["Testing Component"]:::testing
    end
```
