How spygram/learn_tf_modules_workspace works
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 Main · compute Compute Module · vpc VPC Module · output.tf Outputs
Components 18
Root Terraform
Top-level composition and environment wiring
Network
Private network boundary and routing
- VPC Module · Reusable private network boundary
modules/vpc - Network Core · VPC, subnets, and route foundations
modules/vpc/main.tf - Routes · Subnet routing and route table wiring
modules/vpc/routetable.tf - Outputs · Network IDs and connectivity outputs for other modules
modules/vpc/output.tf
Application
WordPress host provisioning and bootstrap
- Compute Module · Reusable WordPress application host
modules/compute - Bootstrap · WordPress installation and startup script
modules/compute/install_wordpress.sh - Security · Instance ingress and egress controls
modules/compute/securitygroup.tf - Key Material · Instance access key provisioning
modules/compute/tlskey.tf - Outputs · Application host connection outputs
modules/compute/output.tf
Data
Managed relational database tier
- RDS Module · Reusable managed database tier
modules/rds - Database · Provisions the persistent relational database
modules/rds/main.tf - Outputs · Database endpoint and connection outputs
modules/rds/output.tf
Automation
Repository validation workflow
- CI Workflow · Validation and plan automation
.github/workflows/ci.yaml
Connections 21
- 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