{"id":33559535,"url":"https://github.com/copubah/aws-load-balancer","last_synced_at":"2026-05-06T04:31:09.085Z","repository":{"id":323348931,"uuid":"1092937142","full_name":"Copubah/AWS-Load-Balancer","owner":"Copubah","description":"Scalable AWS web application with Application Load Balancer, Auto Scaling, and multi-AZ deployment using Terraform","archived":false,"fork":false,"pushed_at":"2025-11-09T15:57:21.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-09T17:29:50.356Z","etag":null,"topics":["alb","auto-scaling","aws","ci-cd","devops","github-actions","infrastructure-as-code","terraform"],"latest_commit_sha":null,"homepage":null,"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/Copubah.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-09T15:49:37.000Z","updated_at":"2025-11-09T15:57:25.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/Copubah/AWS-Load-Balancer","commit_stats":null,"previous_names":["copubah/aws-load-balancer"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Copubah/AWS-Load-Balancer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Copubah%2FAWS-Load-Balancer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Copubah%2FAWS-Load-Balancer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Copubah%2FAWS-Load-Balancer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Copubah%2FAWS-Load-Balancer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Copubah","download_url":"https://codeload.github.com/Copubah/AWS-Load-Balancer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Copubah%2FAWS-Load-Balancer/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","auto-scaling","aws","ci-cd","devops","github-actions","infrastructure-as-code","terraform"],"created_at":"2025-11-27T22:01:15.606Z","updated_at":"2025-11-27T22:02:11.098Z","avatar_url":"https://github.com/Copubah.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AWS Scalable Web Application with Terraform\n\n## Overview\n\nThis project deploys a highly available, scalable web application on AWS using Terraform. It provisions a VPC with multi-AZ architecture, an Application Load Balancer, and an Auto Scaling Group of EC2 instances running Nginx.\n\n## Architecture Diagram\n\n```\n                                    Internet\n                                       |\n                                       |\n                            +----------v-----------+\n                            |  Application Load   |\n                            |     Balancer        |\n                            |   (Public Subnets)  |\n                            +----------+----------+\n                                       |\n                    +------------------+------------------+\n                    |                                     |\n         +----------v-----------+              +----------v-----------+\n         |   Auto Scaling Group |              |   Auto Scaling Group |\n         |    EC2 (Nginx)       |              |    EC2 (Nginx)       |\n         |  Availability Zone A |              |  Availability Zone B |\n         |   (Public Subnet)    |              |   (Public Subnet)    |\n         +----------------------+              +----------------------+\n                    |                                     |\n                    +------------------+------------------+\n                                       |\n                            +----------v-----------+\n                            |        VPC           |\n                            |   CIDR: 10.0.0.0/16  |\n                            +----------------------+\n```\n\n## Features\n\n- Multi-AZ Deployment: Resources distributed across two availability zones for high availability\n- Auto Scaling: Automatically adjusts EC2 instance count based on demand\n- Load Balancing: ALB distributes traffic evenly across healthy instances\n- Modular Design: Reusable Terraform modules for VPC, EC2, ALB, and Security Groups\n- Security: Properly configured security groups with least privilege access\n- Infrastructure as Code: Complete automation using Terraform\n\n## Prerequisites\n\n- AWS Account with appropriate permissions\n- AWS CLI configured with credentials\n- Terraform \u003e= 1.0 installed\n- SSH key pair created in your AWS region (optional, for EC2 access)\n\n## Setup Instructions\n\n### Option 1: Using Deployment Script (Recommended)\n\nThe automated deployment script handles all steps with validation and error checking.\n\n```bash\ncd aws-alb-terraform\n\n# Full deployment with interactive confirmation\n./deploy.sh --deploy\n\n# Or step by step\n./deploy.sh --check      # Check prerequisites\n./deploy.sh --plan       # Create deployment plan\n./deploy.sh --apply      # Apply the plan\n./deploy.sh --output     # Show outputs\n```\n\n### Option 2: Manual Terraform Commands\n\n#### 1. Navigate to Project\n\n```bash\ncd aws-alb-terraform\n```\n\n#### 2. Initialize Terraform\n\n```bash\nterraform init\n```\n\n#### 3. (Optional) Customize Configuration\n\nEdit `terraform.tfvars` (create if needed):\n\n```hcl\naws_region    = \"us-east-1\"\nproject_name  = \"my-web-app\"\ninstance_type = \"t2.micro\"\nmin_size      = 2\nmax_size      = 4\ndesired_size  = 2\n```\n\n#### 4. Plan Deployment\n\n```bash\nterraform plan\n```\n\n#### 5. Deploy Infrastructure\n\n```bash\nterraform apply\n```\n\nType `yes` when prompted to confirm.\n\n#### 6. Access Your Application\n\nAfter deployment completes, Terraform will output the ALB DNS name:\n\n```bash\nalb_dns_name = \"my-web-app-alb-1234567890.us-east-1.elb.amazonaws.com\"\n```\n\nOpen this URL in your browser to see the application.\n\n## Directory Structure\n\n```\naws-alb-terraform/\n├── deploy.sh               # Automated deployment script\n├── destroy.sh              # Automated destruction script\n├── main.tf                 # Root module - orchestrates all resources\n├── variables.tf            # Input variables\n├── outputs.tf              # Output values\n├── provider.tf             # AWS provider configuration\n├── user_data.sh            # EC2 initialization script\n├── terraform.tfvars.example # Example configuration\n├── .gitignore              # Git ignore rules\n├── modules/\n│   ├── vpc/\n│   │   ├── main.tf        # VPC, subnets, IGW, route tables\n│   │   ├── variables.tf\n│   │   └── outputs.tf\n│   ├── security/\n│   │   ├── main.tf        # Security groups for ALB and EC2\n│   │   ├── variables.tf\n│   │   └── outputs.tf\n│   ├── alb/\n│   │   ├── main.tf        # Application Load Balancer, target group, listener\n│   │   ├── variables.tf\n│   │   └── outputs.tf\n│   └── ec2/\n│       ├── main.tf        # Launch template, Auto Scaling Group\n│       ├── variables.tf\n│       └── outputs.tf\n├── README.md               # Complete documentation\n└── QUICKSTART.md           # Quick start guide\n```\n\n## Deployment Scripts\n\n### deploy.sh\n\nAutomated deployment script with the following features:\n- Prerequisites validation (Terraform, AWS CLI, credentials)\n- Terraform initialization and validation\n- Interactive deployment with confirmation\n- Color-coded output for better readability\n- Error handling and rollback support\n\nAvailable Commands:\n```bash\n./deploy.sh --check      # Check prerequisites only\n./deploy.sh --init       # Initialize Terraform\n./deploy.sh --validate   # Validate configuration\n./deploy.sh --plan       # Create deployment plan\n./deploy.sh --apply      # Apply existing plan\n./deploy.sh --deploy     # Full deployment (recommended)\n./deploy.sh --output     # Show deployment outputs\n./deploy.sh --destroy    # Destroy infrastructure\n./deploy.sh --help       # Show help\n```\n\n### destroy.sh\n\nSafe destruction script with:\n- Double confirmation prompts\n- Clear warning about resource deletion\n- Automatic cleanup of all resources\n\n### Makefile\n\nFor developers who prefer Make:\n```bash\nmake help        # Show all available targets\nmake deploy      # Full deployment\nmake plan        # Create deployment plan\nmake destroy     # Destroy infrastructure\nmake format      # Format Terraform code\nmake clean       # Clean Terraform files\n```\n\n## How It Works\n\n### VPC Module\nCreates a Virtual Private Cloud with:\n- CIDR block: 10.0.0.0/16\n- Public subnets in two availability zones\n- Internet Gateway for public internet access\n- Route tables configured for internet routing\n\n### Security Module\nDefines security groups:\n- ALB Security Group: Allows HTTP (port 80) from anywhere\n- EC2 Security Group: Allows HTTP from ALB only, SSH from anywhere (optional)\n\n### ALB Module\nProvisions:\n- Application Load Balancer in public subnets\n- Target group for EC2 instances\n- HTTP listener on port 80\n- Health checks to monitor instance status\n\n### EC2 Module\nCreates:\n- Launch template with Amazon Linux 2 AMI\n- User data script to install and start Nginx\n- Auto Scaling Group with desired capacity\n- Attachment to ALB target group\n\n## Outputs\n\nAfter successful deployment, you'll see:\n\n- `alb_dns_name`: The DNS name to access your application\n- `vpc_id`: The ID of the created VPC\n- `public_subnet_ids`: List of public subnet IDs\n- `asg_name`: Name of the Auto Scaling Group\n\n## Testing\n\n1. Access the Application:\n   ```bash\n   curl http://\u003calb_dns_name\u003e\n   ```\n\n2. Verify Load Balancing:\n   Refresh the page multiple times. The ALB distributes requests across instances.\n\n3. Check Auto Scaling:\n   ```bash\n   aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names \u003casg_name\u003e\n   ```\n\n## Cleanup Instructions\n\n### Option 1: Using Destroy Script (Recommended)\n\n```bash\n./destroy.sh\n```\n\nThe script will prompt for double confirmation before destroying resources.\n\n### Option 2: Using Deployment Script\n\n```bash\n./deploy.sh --destroy\n```\n\n### Option 3: Manual Terraform Command\n\n```bash\nterraform destroy\n```\n\nType `yes` when prompted to confirm.\n\n## Cost Considerations\n\nThis setup uses:\n- EC2 t2.micro instances (Free Tier eligible)\n- Application Load Balancer (~$16-20/month)\n- Data transfer costs\n\nRemember to destroy resources when not in use.\n\n## Customization\n\nModify variables in `variables.tf` or create `terraform.tfvars`:\n- Change instance types\n- Adjust Auto Scaling parameters\n- Modify CIDR blocks\n- Add additional availability zones\n\n## Troubleshooting\n\nIssue: Instances unhealthy in target group\n- Check security group rules\n- Verify user data script executed successfully\n- Review EC2 instance logs\n\nIssue: Cannot access ALB DNS\n- Wait 2-3 minutes for instances to become healthy\n- Verify ALB is in \"active\" state\n- Check security group allows port 80\n\n## Additional Documentation\n\n- QUICKSTART.md - Get started in 3 steps\n- .github-workflows-example.yml - CI/CD template for GitHub Actions\n\n## License\n\nThis project is open source and available for educational purposes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcopubah%2Faws-load-balancer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcopubah%2Faws-load-balancer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcopubah%2Faws-load-balancer/lists"}