This project showcases how to build a fully automated and self-healing web server infrastructure on Amazon Web Services (AWS) using Terraform. If any EC2 instance fails or is terminated, the Auto Scaling Group (ASG) automatically recreates it β ensuring zero downtime and high availability.
β Fully automated AWS infrastructure provisioning via Terraform β Self-healing EC2 instances using Auto Scaling Groups β Application Load Balancer (ALB) for traffic distribution β Nginx web server auto-installed using a user data script β Built entirely as Infrastructure as Code (IaC) β Modular, reusable Terraform configuration
Autonomous-SelfHealing-Infrastructure/
β
βββ main.tf # Core infrastructure definitions
βββ provider.tf # AWS provider configuration
βββ variables.tf # Input variables (region, AMI, instance type, etc.)
βββ security.tf # Security group and firewall rules
βββ vpc.tf # VPC, subnets, and networking configuration
βββ userdata.tpl # Nginx auto-installation and sample HTML page
βββ outputs.tf # ALB DNS output after deployment
βββ .terraform.lock.hcl# Terraform dependency lock file
βββ README.md # Project documentation
Before you begin, make sure you have the following:
- βοΈ AWS Account (with administrative permissions)
- π» AWS CLI installed and configured locally
- π§± Terraform v1.x installed
- π Git installed
git clone https://github.com/AhmadProjects-git/Autonomous-SelfHealing-Infrastructure.git
cd Autonomous-SelfHealing-Infrastructureterraform initterraform planterraform apply -auto-approveβ Terraform will:
- Create a VPC, subnets, and security groups
- Launch an EC2 Auto Scaling Group with Nginx installed
- Configure and attach an Application Load Balancer
- Output the ALB DNS endpoint
Once deployment completes, Terraform will output something like:
alb_dns_name = selfheal-alb-1234567890.us-east-1.elb.amazonaws.com
Open that URL in your browser π Youβll see a green βNginx + Terraform + AWSβ webpage β confirming successful deployment β
- Log in to the AWS Console β EC2 β Instances
- Manually terminate the running instance π§¨
- Watch the Auto Scaling Group automatically launch a new instance π―
Your application will remain available throughout β no downtime!
When youβre done testing, destroy all resources to avoid costs:
terraform destroy -auto-approve- AWS EC2, VPC, ALB, Auto Scaling Groups
- Terraform (IaC)
- Nginx Web Server
- User Data scripting
Developed by: @AhmadProjects-git π GitHub Repository: Autonomous-SelfHealing-Infrastructure
π‘ Found an issue or have ideas to improve?
- Open an Issue
- Or submit a Pull Request
Happy Automating! π€βοΈ Build resilient, self-healing, and autonomous cloud systems β the DevOps way! π©οΈ
π License
This project is licensed under the MIT License. Youβre free to use, modify, and distribute it β just give credit π