This project automates the deployment of the Spring PetClinic application using modern DevOps tools and practices. It provisions infrastructure on AWS using Terraform, configures environments with Ansible, builds and deploys the app through a Jenkins CI/CD pipeline, and containerizes the application using Docker.
This project is based on a modular infrastructure and automated CI/CD pipeline designed using Terraform, Ansible, Jenkins, and Docker on AWS.
The following diagram illustrates the complete infrastructure and CI/CD flow:
.
├── Ansible-Part/ # Ansible playbooks & roles for configuration
├── Docker-Part/ # Dockerfile for app containerization
├── Jenkins-Part/ # Jenkins pipeline script
├── Pics/ # Architecture & pipeline diagrams
├── Scripts/ # Helper bash scripts
├── Source-Code/ # Spring PetClinic source code
└── Terraform-Part/ # Infrastructure as Code for AWS resources
| Tool | Purpose |
|---|---|
| Terraform | Infrastructure provisioning |
| Ansible | Server configuration |
| Jenkins | CI/CD pipeline orchestration |
| Docker | App containerization |
| AWS | Cloud hosting environment |
| Maven | Java project build tool |
Before you begin, ensure you have the following tools installed:
Use the provided script to automatically check:
chmod +x Scripts/check_prerequisites.sh
./Scripts/check_prerequisites.shchmod +x Scripts/infra_setup.sh Scripts/infra_cleanup.sh./Scripts/infra_setup.shThis script performs the following:
-
Provisions AWS infrastructure using Terraform:
- VPC, Subnets, Security Groups, EC2 instances, ALB, and RDS
-
Copies SSH key and Ansible files to Jenkins server
-
Configures Jenkins, Docker, and Maven using Ansible
-
Deploys the Spring PetClinic backend inside a container on Jenkins server
-
Retrieves:
- Jenkins initial admin password and public IP
- RDS Private Endpoint
- Application Load Balancer URL
At this stage, the infrastructure has been provisioned, and the Load Balancer has been created. However, the Target Group will show as unhealthy — this is expected because the application hasn't been deployed yet via Jenkins.
- Open Jenkins URL in browser:
http://<JENKINS_PUBLIC_IP>:8080 - Log in with the retrieved password (printed at the end of
infra_setup.sh)
- Create a new Pipeline job and use the provided
Jenkins-Part/Jenkinsfile
⚠️ Important: Before running the pipeline, make sure to replace the placeholder values<your-dockerhub-user>and<your-rds-endpoint>in theJenkinsfilewith your actual DockerHub username and RDS endpoint.
-
Run the job to:
- Build the application with Maven
- Build and push Docker image to DockerHub
- Deploy the containerized app
Now, the Target Group behind the Load Balancer should show a healthy status — the application container is up and running on the Jenkins server.
Once the Jenkins job completes, access the app at:
http://<ALB_DNS_NAME>:80To destroy everything created and free up AWS resources:
./Scripts/infra_cleanup.shThis script will:
- Terminate all resources provisioned by Terraform
- Delete local key files and temporary artifacts
Mohaned Ahmed Cloud & DevOps Engineer GitHub Profile | LinkedIn










