This project demonstrates the deployment of a scalable web application on AWS using Terraform. The infrastructure is modular, reusable, and adheres to best practices for Infrastructure as Code (IaC).
The infrastructure is organized into modules for better manageability and reusability:
- VPC Module: Creates a Virtual Private Cloud with subnets spread across availability zones.
- EC2 Module: Provisions instances with automated server setup using user data scripts.
- ELB Module: Configures an Elastic Load Balancer for distributing traffic evenly.
- ASG Module: Implements Auto Scaling Groups to handle varying traffic loads.
- Uses user data scripts for server provisioning and setup.
- Automates Apache installation and web page hosting.
- S3 backend with DynamoDB is used for reliable and collaborative Terraform state storage.
- Auto Scaling Groups ensure that the application dynamically adjusts to traffic demands.
- Terraform installed on your local machine.
- AWS CLI configured with appropriate credentials.
- An AWS account.
project-root/
├── modules/
| ├── vpc/ # VPC module
| ├── ec2/ # EC2 module
| ├── elb/ # ELB module
| ├── asg/ # ASG module
├── envs/
| └── scripts/ # User data scripts
└── dev/
| ├── main.tf # Root Terraform configuration
| ├── variable.tf
| ├── backend.tf
| ├── output.tf
| ├── terraform.tfvars
git clone <repository-url>
cd project-rootterraform initterraform validateterraform planterraform apply| Variable | Description | Default Value |
|---|---|---|
ami_id |
AMI ID for EC2 instances | None |
instance_type |
Instance type for EC2 and ASG | t2.micro |
vpc_cidr |
CIDR block for the VPC | 10.0.0.0/16 |
The project provides the following outputs:
- ELB DNS: DNS name of the Elastic Load Balancer.
To destroy the infrastructure, run:
terraform destroyThis project is licensed under the MIT License. See the LICENSE file for details.
- Terraform: HashiCorp
- AWS Documentation
.png)

