{"id":33559560,"url":"https://github.com/adgamal/terraform-aws-scalable-webapp","last_synced_at":"2026-04-17T14:34:44.697Z","repository":{"id":324905320,"uuid":"1098944758","full_name":"AdGamal/terraform-aws-scalable-webapp","owner":"AdGamal","description":"Production-style AWS infrastructure using Terraform (VPC, Subnets, ALB, ASG, Bastion, NAT, IAM, S3).","archived":false,"fork":false,"pushed_at":"2025-11-18T13:23:53.000Z","size":144,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-18T16:07:59.770Z","etag":null,"topics":["alb","autoscaling","aws","devops","infrastructure-iac","s3","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AdGamal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-18T10:52:56.000Z","updated_at":"2025-11-18T13:23:56.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/AdGamal/terraform-aws-scalable-webapp","commit_stats":null,"previous_names":["adgamal/terraform-aws-scalable-webapp"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/AdGamal/terraform-aws-scalable-webapp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdGamal%2Fterraform-aws-scalable-webapp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdGamal%2Fterraform-aws-scalable-webapp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdGamal%2Fterraform-aws-scalable-webapp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdGamal%2Fterraform-aws-scalable-webapp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AdGamal","download_url":"https://codeload.github.com/AdGamal/terraform-aws-scalable-webapp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdGamal%2Fterraform-aws-scalable-webapp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27283994,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-26T02:00:06.075Z","response_time":193,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alb","autoscaling","aws","devops","infrastructure-iac","s3","terraform"],"created_at":"2025-11-27T22:02:50.119Z","updated_at":"2025-11-27T22:02:51.463Z","avatar_url":"https://github.com/AdGamal.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀 Terraform AWS Scalable Web App  \n[![Terraform](https://img.shields.io/badge/Terraform-%3E%3D1.0-623CE4?logo=terraform\u0026logoColor=white)](https://www.terraform.io/)\n[![AWS](https://img.shields.io/badge/AWS-%20Infra-orange?logo=amazon-aws\u0026logoColor=white)](https://aws.amazon.com/)\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)\n\nA production-style AWS architecture deployed entirely with **one Terraform file**.  \nPrivate subnets, internal ALB, Auto Scaling, NAT, IAM, and a bastion host — all stitched together in clean Terraform code.\n\n![Architecture](diagrams/diagram.png)\n---\n\n## 🌐 What This Project Deploys\n\n### **Network Layer**\n- VPC (`10.0.0.0/16`)\n- 2 Public subnets (bastion + NAT)\n- 2 Private subnets (web servers)\n- Internet Gateway  \n- NAT Gateway for outbound traffic\n\n### **Compute \u0026 Scaling**\n- Auto Scaling Group (2–3 EC2 instances)\n- Launch Configuration with HTTP server\n- Private EC2 instances (no public IPs)\n- Bastion host for secure SSH entry\n\n### **Load Balancing**\n- Internal Application Load Balancer  \n- Target Group + HTTP Health Checks  \n- Listener on port 80\n\n### **Security**\n- Bastion SG → SSH from your IP  \n- ALB SG → HTTP from VPC  \n- App SG → HTTP only from ALB  \n- NAT → outbound only  \n- Private workload fully isolated  \n\n### **IAM \u0026 Storage**\n- IAM Role for EC2  \n- IAM Policy for S3 bucket access  \n- Instance Profile  \n- S3 bucket  \n\n---\n\n## 🧩 ASCII Architecture Diagram\n\n ```\n                 ┌──────────────────────────────────────┐\n                 │              Internet                │\n                 └───────────────────┬──────────────────┘\n                                     │\n                                     ▼\n                          ┌──────────────────────┐\n                          │   Bastion Host (22)  │\n                          └──────────┬───────────┘\n                                     │  SSH\n                                     │\n            ┌────────────────────────┼────────────────────────┐\n            │                        │                        │\n            ▼                        ▼                        ▼\n  ┌──────────────────┐      ┌──────────────────┐      ┌──────────────────┐\n  │ Public Subnet A  │      │ Public Subnet B  │      │   Internet GW    │\n  │ (Bastion)        │      │ (NAT Gateway)    │      │ (Outbound only)  │\n  └────────┬─────────┘      └────────┬─────────┘      └────────┬─────────┘\n           │                        │                         │\n           │                        │                         │\n           │                        ▼ NAT                     │\n       ┌──────────────────────────────────────────────────────────┐\n       │                      Private Subnets                     │\n       │   (Web Servers inside Auto Scaling Group)                │\n       │                                                          │\n       │      ┌──────────────────────┐     ┌────────────────────┐ │\n       │      │   Web Server 1       │     │   Web Server 2     │ │\n       │      └──────────┬───────────┘     └──────────┬────────┘  │\n       │                 HTTP (80)                     │          │\n       └──────────────────────────┬────────────────────┼──────────┘\n                                  │                    │\n                                  ▼                    ▼\n                     ┌──────────────────────────────────────────┐\n                     │     Internal Application Load Balancer   │\n                     │              (Listener: 80)              │\n                     └──────────────────────────────────────────┘\n```\n\n\n---\n\n## 📈 Terraform Graph (Conceptual)\n```\nVPC\n├── Subnets\n│ ├── Public A (Bastion)\n│ ├── Public B (NAT)\n│ ├── Private A (ASG)\n│ └── Private B (ASG)\n├── Internet Gateway\n├── NAT Gateway\n├── Route Tables\n│ ├── Public RT → IGW\n│ └── Private RT → NAT\n├── Security Groups\n│ ├── bastion_sg\n│ ├── alb_sg\n│ └── app_sg\n├── ALB\n│ └── Target Group\n│ └── Listener\n├── IAM Role + Instance Profile\n└── Auto Scaling Group\n└── Launch Configuration\n```\n\n---\n\n## ⚙️ How to Deploy\n\n### Initialize Terraform  \n```bash\nterraform init\n```\n\nPreview Infrastructure\n```\nterraform plan\n```\n\nApply Changes\n```\nterraform apply\n```\n\nDestroy Infrastructure\n```\nterraform destroy\n```\n\n## 📌 Usage Examples\n\n1 — SSH into Bastion\n``` \nssh -i my-key.pem ec2-user@$(terraform output -raw bastion_public_ip)\n ```\n\n2 — SSH into Private EC2\n``` \nssh ec2-user@\u003cprivate-ip\u003e\n```\n\n3 — Test Web App\n```\ncurl http://$(terraform output -raw alb_dns_name)\n ```\n\n## 🔐 Security Model\n\n\n| Component       | Allowed Traffic                                     |\n| --------------- | --------------------------------------------------- |\n| **Bastion SG**  | SSH **only from your IP**                           |\n| **ALB SG**      | HTTP **only from inside the VPC**                   |\n| **App SG**      | HTTP **only from ALB SG**                           |\n| **Private EC2** | No public IP — outbound **only via NAT**            |\n| **NAT Gateway** | Outbound internet for updates, S3, package installs |\n\n\n## 📁 Project Structure\n```\nterraform-aws-scalable-webapp/\n└── diagram/\n    └── diagram.png\n│── .github/workflows/\n    └── workflows/\n    └── main_terraform.yml\n│── .gitignore\n│── LICENSE\n│── README_MINIMAL.md\n│── README.md\n│── main.tf\n```\n\n## 🧠 What You Learn  \n• VPC subnet isolation  \n• Internal ALB flow  \n• NAT outbound behavior  \n• IAM roles vs access keys  \n• ASG + ALB integration  \n• Terraform end-to-end wiring\n\n\n## 🏁 Next Enhancements\n\nUpgrades that can turn this into a full production-grade setup:\n\n🔐 Add HTTPS (ACM certificate + ALB HTTPS listener)\n\n🗄️ Add RDS in private subnets for app data\n\n🛡️ Add AWS WAF to protect your ALB\n\n🚀 Add CI/CD pipeline (GitHub Actions → Terraform Cloud or OIDC)\n\n📊 Add CloudWatch alarms \u0026 dashboards\n\n📦 Enable ALB + S3 access logging\n\n🔧 Switch SSH → SSM Session Manager\n\n🛟 Enable AWS Backup snapshots\n\n\n\n## 📜 License\n\nMIT License — free to use, fork, improve.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadgamal%2Fterraform-aws-scalable-webapp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadgamal%2Fterraform-aws-scalable-webapp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadgamal%2Fterraform-aws-scalable-webapp/lists"}