This project automates the deployment of a web application environment on AWS using Terraform. The infrastructure includes a Virtual Private Cloud (VPC) with multiple subnets, security groups, EC2 instances for Jenkins and Docker, an Application Load Balancer (ALB), and an Elastic Container Registry (ECR).
The architecture comprises:
- VPC: Configured with public and private subnets to host resources securely.
- Security Groups: Defined to control inbound and outbound traffic to AWS resources.
- EC2 Instances:
- Jenkins Server: For continuous integration and deployment tasks.
- Docker Host: To run containerized applications.
- Application Load Balancer (ALB): Distributes incoming application traffic across multiple targets, ensuring high availability.
- Elastic Container Registry (ECR): A fully managed Docker container registry that makes it easy to store, manage, and deploy Docker container images.
Before deploying this infrastructure, ensure you have the following:
- AWS Account: Active account with sufficient permissions to create the necessary resources.
- Terraform: Installed on your local machine.
- AWS CLI: Configured with appropriate access credentials.
- SSH Key Pair: An existing key pair in the target AWS region for EC2 instance access.
-
Clone the Repository:
git clone https://github.com/Levi-Michael/terraform-aws-web-app.git cd terraform-aws-web-app
-
Initialize Terraform:
terraform init
-
Upgrade Terraform Providers (if necessary):
terraform init -upgrade
-
Review the Execution Plan:
terraform plan
-
Apply the Configuration:
terraform apply
Note: Review the changes and confirm the application when prompted.
After deployment:
- Access Jenkins: Use the public DNS of the Jenkins EC2 instance to access the Jenkins dashboard.
- Deploy Applications: Utilize the Docker host and ECR to manage and deploy your containerized applications.
To avoid incurring unnecessary charges, destroy the infrastructure when it's no longer needed:
terraform destroy
Ensure that you have backups of any important data before destroying the infrastructure.
Contributions are welcome! Please fork the repository and submit a pull request for any enhancements or bug fixes.
Feel free to reach out for questions, collaboration opportunities or suggestions, open an issue or contact me directly through my GitHub profile.