The project is designed to provision a Sonarqube and MySql server using Docker Containers to be used in this Module.
-
it uses Terraform Scripts as infrastructure as a code (IaC) to create:
- EC2 instance
- VPC
- S3 bucket
- ElasticBeanstalk on high-availability infrastructure (Load Balancer)
- CloudFront
The project will host the maven application that is tested, scanned using Sonarqube, and built using Jenkins pipeline as a CI/CD tool.
.
└── Terraform
├── install.sh
├── main.tf
├── outputs.tf
├── variables.tf
├── modules
├── aws-ec2
│ ├── main.tf
│ ├── outputs.tf
│ └── variables.tf
├── aws-ec2-key
│ ├── main.tf
│ ├── outputs.tf
│ └── variables.tf
├── aws-elasticbeanstalk-cloudfront
│ ├── main.tf
│ ├── outputs.tf
│ └── variables.tf
├── aws-s3bucket
│ ├── main.tf
│ ├── outputs.tf
│ └── variables.tf
└── aws-vpc
├── main.tf
├── outputs.tf
└── variables.tf
to run this deployment pipline follow this steps:
To clone a specific branch:
git clone --branch <branch> <remote_repo_url>
-
add the deployment pipline files in youre project
-
Add the
.gitignore
file content in this repository to the.gitignore
file in your project -
search for /// and fill the necessary changes which are :
-
Run the next commands in main diectory:
-
terraform -chdir=Terraform init
-
terraform -chdir=Terraform plan
-
terraform -chdir=Terraform apply
-
First: Change the
application.properties
- we used a docker container image as our MySql Database
- go to
\src\main\resources\application.properties
and change the Database properties tospring.mvc.view.prefix=/WEB-INF/ spring.datasource.url=jdbc:mysql://public_ip:3306/mysql spring.datasource.username=mysql spring.datasource.password=mysql spring.jpa.hibernate.ddl-auto=create spring.mvc.hiddenmethod.filter.enabled=true
- go to
- we used a docker container image as our MySql Database
-
Secound: SonarQube
-
go to public_ip:9000 which will open the SonarQube Login page
-
Create a SonarQube Project
-
add the values in Jenkinsfile of youre project
-
push it to youre git-hub Repository
-
-
Third: Jenkins server
-
ssh into the aws EC2 instance and run
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
-
copy the password and set up Jenkins at public_ip:8080
-
Jenkins Credentials you need to run this project:
-
-
Forth: Create a pipline in Jenkins
-