# truongntn/terraform-ops-tooling-deployment architecture

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

- Interactive diagram: https://gitdiagram.com/truongntn/terraform-ops-tooling-deployment
- Repository: https://github.com/truongntn/terraform-ops-tooling-deployment

## Overview

##### Main Components
- Infrastructure Provisioning Engine: Represent Terraform as the orchestrator and its various files (main.tf, provider.tf, terraform.tfvars, etc.).
- Modules Layer (Encapsulated Components):
- Instances Module: Deploys compute instances with cloud-init scripts.
- Network Module: Sets up the subnetworks, CIDRs, and related network constructs.
- Security Groups Module: Configures the firewall rules and port-based access controls.
- OpenStack Environment: Illustrate the target environment where OpenStack resources are created.
- Networks: Three key networks as per the README:
- Main Network (10.0.1.0/24), containing HAProxy, DNS, Postfix, and Ansible.
- Core Services Network (10.0.2.0/24), hosting GitLab, Billing, Jenkins, Nexus, FreeIPA, and Snappass.
- Shared Network (10.0.3.0/24) for inter-tenancy communication.
- Access/Configuration: Show how cloud-init initialization is used to set up security (SSH, user configuration) on instances.

##### Relationships and Interactions
- For the Instances module, indicate that instances are provisioned within these networks and configured using cloud-init.
- Security Groups module with both the Network and Instances modules to show that these rules are used to secure traffic flows (for example, control which ports are open within a network).
- Optionally, add an external block for “OpenStack” where Terraform is applying these configurations, clarifying the cloud target.

##### Architectural Patterns and Design Principles
- Modular design: Highlight how the use of Terraform modules (instances, network, security_groups) encapsulates functionality, improving reusability and maintenance.
- Network Segmentation: Emphasize how the three distinct networks provide isolation and controlled communication.
- Security by Design: Identify the use of security groups, limited port exposure, and internal-only SSH access as key security practices.
- Infrastructure as Code (IaC): Show the automated approach towards provisioning using Terraform scripts and variables.

##### Relevant Technologies and Tools
- Terraform and HCL as the configuration language.
- OpenStack as the cloud platform.
- Cloud-init for instance bootstrap and configuration.
- (Implicit) Modules and variable configuration that handle dynamic infrastructure aspects.

- Within the Instances module, further break down service instances by network groupings (Main Network services vs. Core Services, plus shared aspects).
- Security Groups module applying policy to each network or instance group.

## Diagram (Mermaid)

```mermaid
flowchart TD
    TF["Terraform Core"]:::terraform

    %% Terraform Modules Subgraph
    subgraph "Terraform Modules"
        IMod["Instances Module"]:::module
        NMod["Network Module"]:::module
        SMod["Security Groups Module"]:::module
    end

    %% Instances Module Services
    subgraph "Instances Module - Services"
        subgraph "Main Network Services"
            HA["HAProxy"]:::service
            DNS["DNS"]:::service
            Post["Postfix"]:::service
            Ansible["Ansible"]:::service
        end
        subgraph "Core Services"
            GitLab["GitLab"]:::service
            Billing["Billing"]:::service
            Jenkins["Jenkins"]:::service
            Nexus["Nexus"]:::service
            FreeIPA["FreeIPA"]:::service
            Snappass["Snappass"]:::service
        end
        CI["Cloud-init Configuration"]:::init
    end

    %% Networks from Network Module
    subgraph "Provisioned Networks"
        MainNet["Main Network (10.0.1.0/24)"]:::network
        CoreNet["Core Services Network (10.0.2.0/24)"]:::network
        SharedNet["Shared Network (10.0.3.0/24)"]:::network
    end

    OS["OpenStack Environment"]:::openstack

    %% Connections from Terraform Core to Modules
    TF -->|"provisions"| IMod
    TF -->|"provisions"| NMod
    TF -->|"provisions"| SMod

    %% Connections within Instances Module
    IMod -->|"configures"| CI
    IMod -->|"deploys"| HA
    IMod -->|"deploys"| DNS
    IMod -->|"deploys"| Post
    IMod -->|"deploys"| Ansible
    IMod -->|"deploys"| GitLab
    IMod -->|"deploys"| Billing
    IMod -->|"deploys"| Jenkins
    IMod -->|"deploys"| Nexus
    IMod -->|"deploys"| FreeIPA
    IMod -->|"deploys"| Snappass

    %% Connections from Network Module to Networks
    NMod -->|"creates"| MainNet
    NMod -->|"creates"| CoreNet
    NMod -->|"creates"| SharedNet

    %% Service to Network Associations
    HA -->|"attachedTo"| MainNet
    DNS -->|"attachedTo"| MainNet
    Post -->|"attachedTo"| MainNet
    Ansible -->|"attachedTo"| MainNet

    GitLab -->|"attachedTo"| CoreNet
    Billing -->|"attachedTo"| CoreNet
    Jenkins -->|"attachedTo"| CoreNet
    Nexus -->|"attachedTo"| CoreNet
    FreeIPA -->|"attachedTo"| CoreNet
    Snappass -->|"attachedTo"| CoreNet

    %% Security Groups Module applying rules
    SMod ---|"secures"| IMod
    SMod ---|"secures"| NMod

    %% Deployment to OpenStack Environment
    IMod -->|"deploysTo"| OS
    NMod -->|"deploysTo"| OS
    SMod -->|"deploysTo"| OS
    CI -->|"initializes"| OS

    %% Click Events for Component Mappings
    click TF "https://github.com/truongntn/terraform-ops-tooling-deployment/blob/main/main.tf"
    click IMod "https://github.com/truongntn/terraform-ops-tooling-deployment/tree/main/modules/instances"
    click CI "https://github.com/truongntn/terraform-ops-tooling-deployment/blob/main/modules/instances/cloud-init.yml"
    click NMod "https://github.com/truongntn/terraform-ops-tooling-deployment/tree/main/modules/network"
    click SMod "https://github.com/truongntn/terraform-ops-tooling-deployment/tree/main/modules/security_groups"

    %% Styles
    classDef terraform fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef module fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef network fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef service fill:#FFC0CB,stroke:#000,stroke-width:2px;
    classDef openstack fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef init fill:#FFB6C1,stroke:#000,stroke-width:2px;
```
