# spygram/learn_tf_modules_workspace architecture

> Architecture diagram of the GitHub repository spygram/learn_tf_modules_workspace, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/spygram/learn_tf_modules_workspace
- Repository: https://github.com/spygram/learn_tf_modules_workspace

## Overview

This repository is a Terraform workspace that provisions an AWS-based WordPress stack using reusable modules. The architecture is organized around a root deployment layer plus three main infrastructure modules: network, database, and compute.

1. Root orchestration layer  
The top-level Terraform files (`main.tf`, `provider.tf`, `variables.tf`, `data.tf`) act as the composition layer. They wire together the child modules, define shared inputs, and configure the cloud provider. Environment-specific settings are separated into `dev.tfvars` and `prod.tfvars`, suggesting the same infrastructure pattern is deployed to multiple environments with different values.

2. Network subsystem: `modules/vpc`  
The VPC module owns the private network boundary. Its files (`main.tf`, `subnet.tf`, `routetable.tf`, `output.tf`, `var.tf`) indicate it creates the core network primitives: a VPC, subnets, route tables, and related outputs for other modules to consume. This module is the foundation for isolating application and database resources.

3. Compute subsystem: `modules/compute`  
The compute module is the application tier. Based on `install_wordpress.sh`, `securitygroup.tf`, `tlskey.tf`, and `main.tf`, it likely provisions an EC2-based WordPress host, configures instance access, attaches security groups, and bootstraps WordPress installation at launch. The presence of a TLS key module suggests SSH or instance access key material is managed here as part of compute provisioning.

4. Database subsystem: `modules/rds`  
The RDS module represents the managed database tier. Its `main.tf`, `var.tf`, and `output.tf` imply it provisions a relational database instance and exports connection details for the application layer. In a WordPress architecture, this is the persistent data store that the compute tier connects to.

5. Data flow between modules  
The primary data flow is: root module -> VPC module for network creation -> RDS module for database provisioning inside the network -> compute module for the WordPress server, which consumes database outputs and network/security inputs. Outputs from the VPC and RDS modules are likely used as inputs to the compute module so that the application can reach the database over the private network.

6. Security boundaries  
Security is enforced at least at the network and instance layers. The dedicated `securitygroup.tf` in the compute module indicates ingress/egress control for the WordPress host, and the VPC module provides the isolation boundary for separating public/private resources. The architecture likely keeps the database off the public internet and exposes only the application entry point.

7. Configuration and environment management  
`dev.tfvars` and `prod.tfvars` imply environment-specific deployment parameters such as CIDRs, instance sizing, database settings, or naming. This separates reusable infrastructure code from deployment configuration, which is important for diagramming where the same topology is reused with different values.

8. Provider and shared data sources  
`provider.tf` defines the cloud/provider integration, which is the external platform dependency for the whole stack. `data.tf` files in the root and compute module indicate some values are discovered dynamically from the cloud environment rather than hardcoded, which affects how resources are connected and referenced.

9. Module output contract  
Each module has an `output.tf`, signaling a clear interface between components. The modules are not tightly coupled; instead, they expose resource IDs, endpoints, and other connection details that the root module can pass downstream. This makes the architecture modular and diagram-friendly: each box has a defined input/output boundary.

10. CI/CD and validation  
`.github/workflows/ci.yaml` shows the repository includes automation for Terraform validation or plan checks in GitHub Actions. This is not part of the deployed infrastructure, but it is part of the delivery architecture and governs how changes are verified before applying to AWS.

11. Likely end-to-end deployment shape  
At a high level, the deployed system is a three-tier WordPress setup on AWS: network foundation, managed database, and an EC2-based application server. The app tier bootstraps WordPress via a shell script, and the database tier provides persistence. The VPC module underpins both tiers and defines the connectivity boundaries between them.

12. Diagramming guidance  
For an accurate architecture diagram, represent the repository as a Terraform root module composing three infrastructure modules. Show the VPC as the outer boundary, the RDS instance as a private data store, and the compute node as the WordPress application host. Indicate that the root module and environment tfvars control deployment, while GitHub Actions provides pre-deployment automation.

Main entry points: [`main.tf`](https://github.com/spygram/learn_tf_modules_workspace/blob/main/main.tf) (Main), [`modules/compute`](https://github.com/spygram/learn_tf_modules_workspace/tree/main/modules/compute) (Compute Module), [`modules/vpc`](https://github.com/spygram/learn_tf_modules_workspace/tree/main/modules/vpc) (VPC Module), [`modules/vpc/output.tf`](https://github.com/spygram/learn_tf_modules_workspace/blob/main/modules/vpc/output.tf) (Outputs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_root["Root Terraform"]
  node_root_main["Main<br/>terraform root<br/>[main.tf]"]
  node_root_provider["Provider<br/>terraform config<br/>[provider.tf]"]
  node_root_vars["Vars<br/>terraform inputs<br/>[variables.tf]"]
  node_root_data["Data<br/>[data.tf]"]
  node_env_cfg["Env tfvars<br/>deployment config"]
end

subgraph group_network["Network"]
  node_vpc_mod[("VPC Module<br/>network module")]
  node_vpc_core["Network Core<br/>vpc/subnets<br/>[main.tf]"]
  node_vpc_routes["Routes<br/>routing<br/>[routetable.tf]"]
  node_vpc_outputs["Outputs<br/>[output.tf]"]
end

subgraph group_compute["Application"]
  node_compute_mod[("Compute Module<br/>application module")]
  node_compute_boot["Bootstrap<br/>instance init"]
  node_compute_sec{{"Security<br/>[securitygroup.tf]"}}
  node_compute_key["Key Material<br/>access key<br/>[tlskey.tf]"]
  node_compute_outputs["Outputs<br/>[output.tf]"]
end

subgraph group_database["Data"]
  node_rds_mod[("RDS Module<br/>database module")]
  node_rds_main["Database<br/>rds instance<br/>[main.tf]"]
  node_rds_outputs["Outputs<br/>[output.tf]"]
end

subgraph group_automation["Automation"]
  node_ci_workflow["CI Workflow<br/>github actions<br/>[ci.yaml]"]
end

node_root_main -->|"uses"| node_root_provider
node_root_main -->|"reads"| node_root_vars
node_root_main -->|"reads"| node_root_data
node_root_main -.->|"selects"| node_env_cfg
node_root_main -->|"creates"| node_vpc_mod
node_root_main -->|"creates"| node_rds_mod
node_root_main -->|"creates"| node_compute_mod
node_vpc_mod -->|"contains"| node_vpc_core
node_vpc_mod -->|"contains"| node_vpc_routes
node_vpc_mod -->|"exports"| node_vpc_outputs
node_rds_mod -->|"contains"| node_rds_main
node_rds_mod -->|"exports"| node_rds_outputs
node_compute_mod -->|"boots"| node_compute_boot
node_compute_mod -->|"contains"| node_compute_sec
node_compute_mod -->|"contains"| node_compute_key
node_compute_mod -->|"exports"| node_compute_outputs
node_vpc_outputs -.->|"subnet/input"| node_rds_main
node_vpc_outputs -.->|"network/input"| node_compute_mod
node_rds_outputs -.->|"db settings"| node_compute_boot
node_compute_sec -.->|"restricts"| node_rds_main
node_ci_workflow -.->|"validates"| node_root_main

click node_root_main "https://github.com/spygram/learn_tf_modules_workspace/blob/main/main.tf"
click node_root_provider "https://github.com/spygram/learn_tf_modules_workspace/blob/main/provider.tf"
click node_root_vars "https://github.com/spygram/learn_tf_modules_workspace/blob/main/variables.tf"
click node_root_data "https://github.com/spygram/learn_tf_modules_workspace/blob/main/data.tf"
click node_vpc_mod "https://github.com/spygram/learn_tf_modules_workspace/tree/main/modules/vpc"
click node_vpc_core "https://github.com/spygram/learn_tf_modules_workspace/blob/main/modules/vpc/main.tf"
click node_vpc_routes "https://github.com/spygram/learn_tf_modules_workspace/blob/main/modules/vpc/routetable.tf"
click node_vpc_outputs "https://github.com/spygram/learn_tf_modules_workspace/blob/main/modules/vpc/output.tf"
click node_rds_mod "https://github.com/spygram/learn_tf_modules_workspace/tree/main/modules/rds"
click node_rds_main "https://github.com/spygram/learn_tf_modules_workspace/blob/main/modules/rds/main.tf"
click node_rds_outputs "https://github.com/spygram/learn_tf_modules_workspace/blob/main/modules/rds/output.tf"
click node_compute_mod "https://github.com/spygram/learn_tf_modules_workspace/tree/main/modules/compute"
click node_compute_boot "https://github.com/spygram/learn_tf_modules_workspace/blob/main/modules/compute/install_wordpress.sh"
click node_compute_sec "https://github.com/spygram/learn_tf_modules_workspace/blob/main/modules/compute/securitygroup.tf"
click node_compute_key "https://github.com/spygram/learn_tf_modules_workspace/blob/main/modules/compute/tlskey.tf"
click node_compute_outputs "https://github.com/spygram/learn_tf_modules_workspace/blob/main/modules/compute/output.tf"
click node_ci_workflow "https://github.com/spygram/learn_tf_modules_workspace/blob/main/.github/workflows/ci.yaml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_root_main,node_root_provider,node_root_vars,node_root_data,node_env_cfg toneBlue
class node_vpc_mod,node_vpc_core,node_vpc_routes,node_vpc_outputs toneAmber
class node_compute_mod,node_compute_boot,node_compute_sec,node_compute_key,node_compute_outputs toneMint
class node_rds_mod,node_rds_main,node_rds_outputs toneRose
class node_ci_workflow toneIndigo
```

## Components

### Root Terraform

Top-level composition and environment wiring

- [Main](https://github.com/spygram/learn_tf_modules_workspace/blob/main/main.tf): terraform root · Composes the child modules and deployment stack · `main.tf`
- [Provider](https://github.com/spygram/learn_tf_modules_workspace/blob/main/provider.tf): terraform config · Cloud provider configuration · `provider.tf`
- [Vars](https://github.com/spygram/learn_tf_modules_workspace/blob/main/variables.tf): terraform inputs · Shared root-level variables · `variables.tf`
- [Data](https://github.com/spygram/learn_tf_modules_workspace/blob/main/data.tf): terraform data · Root data sources and discovered values · `data.tf`
- **Env tfvars**: deployment config · Environment-specific deployment values

### Network

Private network boundary and routing

- [VPC Module](https://github.com/spygram/learn_tf_modules_workspace/tree/main/modules/vpc): network module · Reusable private network boundary · `modules/vpc`
- [Network Core](https://github.com/spygram/learn_tf_modules_workspace/blob/main/modules/vpc/main.tf): vpc/subnets · VPC, subnets, and route foundations · `modules/vpc/main.tf`
- [Routes](https://github.com/spygram/learn_tf_modules_workspace/blob/main/modules/vpc/routetable.tf): routing · Subnet routing and route table wiring · `modules/vpc/routetable.tf`
- [Outputs](https://github.com/spygram/learn_tf_modules_workspace/blob/main/modules/vpc/output.tf): module outputs · Network IDs and connectivity outputs for other modules · `modules/vpc/output.tf`

### Application

WordPress host provisioning and bootstrap

- [Compute Module](https://github.com/spygram/learn_tf_modules_workspace/tree/main/modules/compute): application module · Reusable WordPress application host · `modules/compute`
- [Bootstrap](https://github.com/spygram/learn_tf_modules_workspace/blob/main/modules/compute/install_wordpress.sh): instance init · WordPress installation and startup script · `modules/compute/install_wordpress.sh`
- [Security](https://github.com/spygram/learn_tf_modules_workspace/blob/main/modules/compute/securitygroup.tf): security group · Instance ingress and egress controls · `modules/compute/securitygroup.tf`
- [Key Material](https://github.com/spygram/learn_tf_modules_workspace/blob/main/modules/compute/tlskey.tf): access key · Instance access key provisioning · `modules/compute/tlskey.tf`
- [Outputs](https://github.com/spygram/learn_tf_modules_workspace/blob/main/modules/compute/output.tf): module outputs · Application host connection outputs · `modules/compute/output.tf`

### Data

Managed relational database tier

- [RDS Module](https://github.com/spygram/learn_tf_modules_workspace/tree/main/modules/rds): database module · Reusable managed database tier · `modules/rds`
- [Database](https://github.com/spygram/learn_tf_modules_workspace/blob/main/modules/rds/main.tf): rds instance · Provisions the persistent relational database · `modules/rds/main.tf`
- [Outputs](https://github.com/spygram/learn_tf_modules_workspace/blob/main/modules/rds/output.tf): module outputs · Database endpoint and connection outputs · `modules/rds/output.tf`

### Automation

Repository validation workflow

- [CI Workflow](https://github.com/spygram/learn_tf_modules_workspace/blob/main/.github/workflows/ci.yaml): github actions · Validation and plan automation · `.github/workflows/ci.yaml`

## Connections

- Main → Provider: uses · Root stack is configured through the provider
- Main → Vars: reads · Root module consumes shared variables
- Main → Data: reads · Root module uses discovered values
- Main → Env tfvars: selects · Environment tfvars drive deployment values
- Main → VPC Module: creates · Root composes the network module
- Main → RDS Module: creates · Root composes the database module
- Main → Compute Module: creates · Root composes the application module
- VPC Module → Network Core: contains · VPC module defines the core network resources
- VPC Module → Routes: contains · VPC module manages subnet routing
- VPC Module → Outputs: exports · Network outputs are consumed downstream
- RDS Module → Database: contains · RDS module provisions the database tier
- RDS Module → Outputs: exports · Database connection details are exposed
- Compute Module → Bootstrap: boots · WordPress is installed during instance initialization
- Compute Module → Security: contains · Compute module defines host access controls
- Compute Module → Key Material: contains · Compute module manages access key material
- Compute Module → Outputs: exports · Application host outputs are exposed to root
- Outputs → Database: subnet/input · Database is placed using network outputs
- Outputs → Compute Module: network/input · Application tier consumes private network details
- Outputs → Bootstrap: db settings · Bootstrap uses database connection details
- Security → Database: restricts · Security boundaries keep database private
- CI Workflow → Main: validates · CI checks repository changes before deploy
