# reticent93/pilot_light_dr_recovery architecture

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

- Interactive diagram: https://gitdiagram.com/reticent93/pilot_light_dr_recovery
- Repository: https://github.com/reticent93/pilot_light_dr_recovery

## Overview

This repository is Terraform infrastructure for AWS pilot-light disaster recovery across primary and secondary regions. The documented workflow monitors primary load-balancer health, triggers failover automation, scales the secondary Auto Scaling Group, and notifies administrators; traffic is switched by moving an Elastic IP, with DNS updates described as a manual recovery option. The graph also preserves the documented cross-region data, networking, security, and monitoring capabilities. Source excerpts show the Lambda’s ASG, instance-polling, EIP, and SNS actions; other module relationships rely on README descriptions, not inspected Terraform wiring.

Main entry points: [`environments/primary/main.tf`](https://github.com/reticent93/pilot_light_dr_recovery/blob/main/environments/primary/main.tf) (Primary environment), [`environments/secondary/main.tf`](https://github.com/reticent93/pilot_light_dr_recovery/blob/main/environments/secondary/main.tf) (Secondary environment), [`modules/automation/lambda/failover.py`](https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/automation/lambda/failover.py) (Failover Lambda), [`modules/asg/main.tf`](https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/asg/main.tf) (Auto Scaling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_deployment["Regional deployment"]
  node_global_env["Global environment<br/>[main.tf]"]
  node_primary_env["Primary environment<br/>[main.tf]"]
  node_secondary_env["Secondary environment<br/>[main.tf]"]
end

subgraph group_compute["Application infrastructure"]
  node_vpc["VPC networking<br/>[main.tf]"]
  node_alb["Load balancer<br/>[main.tf]"]
  node_asg["Auto Scaling<br/>[main.tf]"]
end

subgraph group_recovery["Failover and monitoring"]
  node_monitoring["Health monitoring<br/>[main.tf]"]
  node_dns["DNS failover<br/>[main.tf]"]
  node_automation["Failover Lambda<br/>[failover.py]"]
  node_automation_infra["Automation setup<br/>[main.tf]"]
  node_notifications["SNS notifications<br/>[main.tf]"]
end

subgraph group_data["Replicated data and security"]
  node_dynamodb[("DynamoDB global tables<br/>[main.tf]")]
  node_s3[("S3 replication<br/>[main.tf]")]
  node_iam["IAM permissions<br/>[main.tf]"]
  node_security_groups["Security groups<br/>[main.tf]"]
end

node_operator(("Administrators"))
node_cloudwatch["CloudWatch alarms"]
node_eventbridge["EventBridge rule"]
node_sns_service["Amazon SNS"]
node_elastic_ip["Elastic IP"]

node_operator -->|"deploys"| node_global_env
node_operator -->|"deploys"| node_primary_env
node_operator -->|"deploys"| node_secondary_env
node_primary_env -.->|"provisions"| node_alb
node_primary_env -.->|"provisions"| node_asg
node_secondary_env -.->|"provisions"| node_asg
node_monitoring -->|"checks health"| node_alb
node_cloudwatch -->|"triggers"| node_eventbridge
node_eventbridge -->|"invokes"| node_automation
node_automation -->|"scales"| node_asg
node_automation -->|"associates"| node_elastic_ip
node_automation -->|"publishes"| node_sns_service
node_sns_service -->|"alerts"| node_operator
node_operator -->|"updates manually"| node_dns
node_primary_env -.->|"configures"| node_vpc
node_secondary_env -.->|"configures"| node_vpc
node_primary_env -.->|"deploys"| node_dynamodb
node_secondary_env -.->|"deploys"| node_dynamodb
node_primary_env -.->|"deploys"| node_s3
node_secondary_env -.->|"deploys"| node_s3
node_primary_env -.->|"configures"| node_iam
node_primary_env -.->|"configures"| node_security_groups

click node_global_env "https://github.com/reticent93/pilot_light_dr_recovery/blob/main/environments/global/main.tf"
click node_primary_env "https://github.com/reticent93/pilot_light_dr_recovery/blob/main/environments/primary/main.tf"
click node_secondary_env "https://github.com/reticent93/pilot_light_dr_recovery/blob/main/environments/secondary/main.tf"
click node_vpc "https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/vpc/main.tf"
click node_alb "https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/load-balancer/main.tf"
click node_asg "https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/asg/main.tf"
click node_monitoring "https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/monitoring/main.tf"
click node_dns "https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/dns-failover/main.tf"
click node_automation "https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/automation/lambda/failover.py"
click node_automation_infra "https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/automation/main.tf"
click node_notifications "https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/notifications/main.tf"
click node_dynamodb "https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/dynamodb/main.tf"
click node_s3 "https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/storage/S3/main.tf"
click node_iam "https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/iam/main.tf"
click node_security_groups "https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/security-groups/main.tf"

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_global_env,node_primary_env,node_secondary_env toneBlue
class node_vpc,node_alb,node_asg toneAmber
class node_monitoring,node_dns,node_automation,node_automation_infra,node_notifications toneMint
class node_dynamodb,node_s3,node_iam,node_security_groups toneRose
class node_operator,node_cloudwatch,node_eventbridge,node_sns_service,node_elastic_ip toneIndigo
```

## Components

### Regional deployment

- [Global environment](https://github.com/reticent93/pilot_light_dr_recovery/blob/main/environments/global/main.tf): `environments/global/main.tf`
- [Primary environment](https://github.com/reticent93/pilot_light_dr_recovery/blob/main/environments/primary/main.tf): `environments/primary/main.tf`
- [Secondary environment](https://github.com/reticent93/pilot_light_dr_recovery/blob/main/environments/secondary/main.tf): `environments/secondary/main.tf`

### Application infrastructure

- [VPC networking](https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/vpc/main.tf): `modules/vpc/main.tf`
- [Load balancer](https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/load-balancer/main.tf): `modules/load-balancer/main.tf`
- [Auto Scaling](https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/asg/main.tf): `modules/asg/main.tf`

### Failover and monitoring

- [Health monitoring](https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/monitoring/main.tf): `modules/monitoring/main.tf`
- [DNS failover](https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/dns-failover/main.tf): `modules/dns-failover/main.tf`
- [Failover Lambda](https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/automation/lambda/failover.py): `modules/automation/lambda/failover.py`
- [Automation setup](https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/automation/main.tf): `modules/automation/main.tf`
- [SNS notifications](https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/notifications/main.tf): `modules/notifications/main.tf`

### Replicated data and security

- [DynamoDB global tables](https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/dynamodb/main.tf): `modules/dynamodb/main.tf`
- [S3 replication](https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/storage/S3/main.tf): `modules/storage/S3/main.tf`
- [IAM permissions](https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/iam/main.tf): `modules/iam/main.tf`
- [Security groups](https://github.com/reticent93/pilot_light_dr_recovery/blob/main/modules/security-groups/main.tf): `modules/security-groups/main.tf`

### Other components

- **Administrators**
- **CloudWatch alarms**
- **EventBridge rule**
- **Amazon SNS**
- **Elastic IP**

## Connections

- Administrators → Global environment: deploys (evidence: `README.md`)
- Administrators → Primary environment: deploys (evidence: `README.md`)
- Administrators → Secondary environment: deploys (evidence: `README.md`)
- Primary environment → Load balancer: provisions (evidence: `README.md`)
- Primary environment → Auto Scaling: provisions (evidence: `README.md`)
- Secondary environment → Auto Scaling: provisions (evidence: `README.md`)
- Health monitoring → Load balancer: checks health (evidence: `README.md`)
- CloudWatch alarms → EventBridge rule: triggers (evidence: `README.md`)
- EventBridge rule → Failover Lambda: invokes (evidence: `README.md`)
- Failover Lambda → Auto Scaling: scales (evidence: `modules/automation/lambda/failover.py`)
- Failover Lambda → Elastic IP: associates (evidence: `modules/automation/lambda/failover.py`)
- Failover Lambda → Amazon SNS: publishes (evidence: `modules/automation/lambda/failover.py`)
- Amazon SNS → Administrators: alerts (evidence: `README.md`)
- Administrators → DNS failover: updates manually (evidence: `README.md`)
- Primary environment → VPC networking: configures (evidence: `README.md`)
- Secondary environment → VPC networking: configures (evidence: `README.md`)
- Primary environment → DynamoDB global tables: deploys (evidence: `README.md`)
- Secondary environment → DynamoDB global tables: deploys (evidence: `README.md`)
- Primary environment → S3 replication: deploys (evidence: `README.md`)
- Secondary environment → S3 replication: deploys (evidence: `README.md`)
- Primary environment → IAM permissions: configures (evidence: `README.md`)
- Primary environment → Security groups: configures (evidence: `README.md`)
