# ayushbhartiya01/aws-terraform-labs architecture

> Architecture diagram of the GitHub repository ayushbhartiya01/aws-terraform-labs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ayushbhartiya01/aws-terraform-labs
- Repository: https://github.com/ayushbhartiya01/aws-terraform-labs

## Overview

This repository is Terraform infrastructure for a multi-tier AWS web application. Its documented deployment workflow initializes shared remote state, provisions MySQL as an independently managed data tier, then deploys the web tier; the web tier exposes traffic through an ALB to autoscaled EC2 compute in isolated public/private network tiers. The README also describes state locking and a LocalStack-based local workflow. Source excerpts were not provided, so relationships below are limited to those documented in the README; paths for described but unsampled components use their existing Terraform directories.

Main entry points: [`stage/services/webserver-cluster`](https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/services/webserver-cluster) (VPC network), [`global/s3`](https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/global/s3) (S3 state storage), [`stage/data-stores/mysql`](https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/data-stores/mysql) (RDS MySQL), [`setup-local.sh`](https://github.com/ayushbhartiya01/aws-terraform-labs/blob/main/setup-local.sh) (Local environment setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_state["State infrastructure"]
  node_state_storage[("S3 state storage")]
  node_state_locking[("DynamoDB locking")]
end

subgraph group_data["Data tier"]
  node_mysql[("RDS MySQL")]
  node_remote_state["Remote-state lookup"]
end

subgraph group_application["Application network"]
  node_vpc["VPC network"]
  node_public_subnets["Public subnets"]
  node_private_subnets["Private subnets"]
  node_alb["Application load balancer"]
  node_health_checks["Health checks"]
  node_asg["Auto Scaling Group"]
  node_launch_template["Launch template"]
  node_ec2["EC2 instances"]
end

subgraph group_local["Local sandbox"]
  node_local_setup["Local environment setup<br/>[setup-local.sh]"]
  node_localstack["LocalStack emulator"]
end

node_operator(("Terraform operator"))
node_browser(("Browser user"))

node_operator -->|"initializes and applies"| node_state_storage
node_operator -->|"deploys data tier"| node_mysql
node_operator -->|"deploys application tier"| node_vpc
node_mysql -->|"persists state"| node_state_storage
node_vpc -->|"persists state"| node_state_storage
node_state_storage -->|"uses locking"| node_state_locking
node_remote_state -->|"looks up state"| node_mysql
node_vpc -->|"uses lookup"| node_remote_state
node_vpc -->|"spans three AZs"| node_public_subnets
node_vpc -->|"spans three AZs"| node_private_subnets
node_alb -->|"uses ingress tier"| node_public_subnets
node_asg -->|"uses application tier"| node_private_subnets
node_asg -->|"uses configuration"| node_launch_template
node_launch_template -->|"configures instances"| node_ec2
node_alb -->|"distributes HTTP traffic"| node_ec2
node_alb -->|"executes checks"| node_health_checks
node_browser -->|"sends HTTP traffic"| node_alb
node_operator -->|"sources script"| node_local_setup
node_local_setup -->|"configures endpoints"| node_localstack
node_localstack -->|"hosts local state"| node_state_storage

click node_state_storage "https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/global/s3"
click node_state_locking "https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/global/s3"
click node_mysql "https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/data-stores/mysql"
click node_remote_state "https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/data-stores/mysql"
click node_vpc "https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/services/webserver-cluster"
click node_public_subnets "https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/services/webserver-cluster"
click node_private_subnets "https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/services/webserver-cluster"
click node_alb "https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/services/webserver-cluster"
click node_health_checks "https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/services/webserver-cluster"
click node_asg "https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/services/webserver-cluster"
click node_launch_template "https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/services/webserver-cluster"
click node_ec2 "https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/services/webserver-cluster"
click node_local_setup "https://github.com/ayushbhartiya01/aws-terraform-labs/blob/main/setup-local.sh"

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_state_storage,node_state_locking,node_browser toneBlue
class node_mysql,node_remote_state toneAmber
class node_vpc,node_public_subnets,node_private_subnets,node_alb,node_health_checks,node_asg,node_launch_template,node_ec2 toneMint
class node_local_setup,node_localstack toneRose
class node_operator toneIndigo
```

## Components

### State infrastructure

- [S3 state storage](https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/global/s3): `global/s3`
- [DynamoDB locking](https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/global/s3): `global/s3`

### Data tier

- [RDS MySQL](https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/data-stores/mysql): `stage/data-stores/mysql`
- [Remote-state lookup](https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/data-stores/mysql): `stage/data-stores/mysql`

### Application network

- [VPC network](https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/services/webserver-cluster): `stage/services/webserver-cluster`
- [Public subnets](https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/services/webserver-cluster): `stage/services/webserver-cluster`
- [Private subnets](https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/services/webserver-cluster): `stage/services/webserver-cluster`
- [Application load balancer](https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/services/webserver-cluster): `stage/services/webserver-cluster`
- [Health checks](https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/services/webserver-cluster): `stage/services/webserver-cluster`
- [Auto Scaling Group](https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/services/webserver-cluster): `stage/services/webserver-cluster`
- [Launch template](https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/services/webserver-cluster): `stage/services/webserver-cluster`
- [EC2 instances](https://github.com/ayushbhartiya01/aws-terraform-labs/tree/main/stage/services/webserver-cluster): `stage/services/webserver-cluster`

### Local sandbox

- [Local environment setup](https://github.com/ayushbhartiya01/aws-terraform-labs/blob/main/setup-local.sh): `setup-local.sh`
- **LocalStack emulator**

### Other components

- **Terraform operator**
- **Browser user**

## Connections

- Terraform operator → S3 state storage: initializes and applies (evidence: `README.md`)
- Terraform operator → RDS MySQL: deploys data tier (evidence: `README.md`)
- Terraform operator → VPC network: deploys application tier (evidence: `README.md`)
- RDS MySQL → S3 state storage: persists state (evidence: `README.md`)
- VPC network → S3 state storage: persists state (evidence: `README.md`)
- S3 state storage → DynamoDB locking: uses locking (evidence: `README.md`)
- Remote-state lookup → RDS MySQL: looks up state (evidence: `README.md`)
- VPC network → Remote-state lookup: uses lookup (evidence: `README.md`)
- VPC network → Public subnets: spans three AZs (evidence: `README.md`)
- VPC network → Private subnets: spans three AZs (evidence: `README.md`)
- Application load balancer → Public subnets: uses ingress tier (evidence: `README.md`)
- Auto Scaling Group → Private subnets: uses application tier (evidence: `README.md`)
- Auto Scaling Group → Launch template: uses configuration (evidence: `README.md`)
- Launch template → EC2 instances: configures instances (evidence: `README.md`)
- Application load balancer → EC2 instances: distributes HTTP traffic (evidence: `README.md`)
- Application load balancer → Health checks: executes checks (evidence: `README.md`)
- Browser user → Application load balancer: sends HTTP traffic (evidence: `README.md`)
- Terraform operator → Local environment setup: sources script (evidence: `README.md`)
- Local environment setup → LocalStack emulator: configures endpoints (evidence: `README.md`)
- LocalStack emulator → S3 state storage: hosts local state (evidence: `README.md`)
