https://github.com/zapwap123/aws-infrastucture-for-disaster-recovery-with-terraform
This project provisions a complete Disaster Recovery (DR) infrastructure for a LAMP stack web application using Terraform on AWS.
https://github.com/zapwap123/aws-infrastucture-for-disaster-recovery-with-terraform
aws aws-lambda disaster-recovery ecs-fargate terraform terraform-modules
Last synced: 3 months ago
JSON representation
This project provisions a complete Disaster Recovery (DR) infrastructure for a LAMP stack web application using Terraform on AWS.
- Host: GitHub
- URL: https://github.com/zapwap123/aws-infrastucture-for-disaster-recovery-with-terraform
- Owner: Zapwap123
- Created: 2025-07-14T16:40:44.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-07-18T10:26:42.000Z (4 months ago)
- Last Synced: 2025-07-22T00:02:05.047Z (3 months ago)
- Topics: aws, aws-lambda, disaster-recovery, ecs-fargate, terraform, terraform-modules
- Language: HCL
- Homepage:
- Size: 200 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AWS Infrastructure for Disaster Recovery (Terraform)
This project provisions a complete Disaster Recovery (DR) infrastructure for a LAMP stack web application using **Terraform** on **AWS**, including:
- ECS Fargate Cluster (DR)
- RDS MySQL Read Replica
- Application Load Balancer (ALB)
- VPC with public/private subnets, NAT gateways
- Lambda + EventBridge trigger for automatic failover
## 📦 ALB Links Application
`Primary: `
```
http://ecs-lamp-alb-1868910702.eu-west-1.elb.amazonaws.com
```
And
`Disaster Recovery: `
```
http://ecs-lamp-dr-alb-1828828452.eu-central-1.elb.amazonaws.com
```
## 🚀 Architecture Overview
```
┌──────────────────────────────┐
│ Primary Region │
│ - ECS Fargate │
│ - RDS (MySQL) │
│ - ALB │
└──────────────────────────────┘
⬇ EventBridge Trigger
┌──────────────────────────────┐
│ Disaster Recovery Region │
│ - ECS Cluster (Fargate) │
│ - RDS Read Replica │
│ - ALB │
└──────────────────────────────┘
```
## 🧱 Architecture

## 📦 Module Breakdown
- `network/`: VPC, subnets, IGW, NAT, routes
- `alb/`: Application Load Balancer and Target Group
- `ecs/`: ECS Cluster, Task Definitions, and Service
- `rds/`: MySQL Read Replica
- `dr_trigger/`: CloudWatch Alarm, EventBridge, and Lambda
## 🛠️ Prerequisites
- AWS CLI configured (`aws configure`)
- Terraform v1.3+
- AWS credentials with sufficient privileges
## ⚙️ Setup Instructions
1. **Clone the Repository**
```bash
git clone https://github.com/Zapwap123/AWS-Infrastructure-For-Disaster-Recovery-With-Terraform.git
cd AWS-Infrastructure-For-Disaster-Recovery-With-Terraform
```
2. **Configure Variables**
Update `dr.tfvars` with your actual AWS resource ARNs, secret ARNs, ECR image URI, etc.
3. **Initialize Terraform**
```bash
terraform init
```
4. **Plan the Deployment**
```bash
terraform plan -var-file="dr.tfvars" -out=dr-plan.tfplan
```
5. **Apply the Deployment**
```bash
terraform apply "dr-plan.tfplan"
```
## ✅ Outputs
- `dr_alb_dns_name`: DR ALB DNS
- `dr_rds_endpoint`: RDS read replica endpoint
- `dr_ecs_cluster`: DR ECS Cluster ARN
- `dr_ecs_service_name`: DR ECS Service
## 📌 Notes
- This infrastructure is deployed in the `eu-central-1` region as DR.
- Make sure your secrets in Secrets Manager follow the expected naming scheme.
- The failover trigger is automatic based on unhealthy host metrics from primary ALB.
## 🙋♂️ Maintainer
Seth Anmawen — [github.com/Zapwap123](https://github.com/Zapwap123)