RDS integration with Jnekins/EC2
2 min read

In this document, I am showing how to create EBS (MySQL) and then connect to MySQL using the terminal.
I created a small RDS_APP (Flask application) where I store names and roll numbers and view them all.
I also created an automation pipeline where I am doing the following:
- Clone the app
- Build the image
- Push to Docker Hub
- SSH to EC2
- Pull the image
- Run the container
Cretaing RDS

here i create simple RDS Mysql database , with config of free account
Connecting the Terminal to RDS
1st pull mysql image (public image of Mysql)
docker pull mysql:latest2nd i ran mysql container with RDS configrations
dheeren:~$ docker run -d --name my-mysql -e MYSQL_ROOT_PASSWORD=Abcd12345 -e MYSQL_DATABASE=studentdb -e MYSQL_USER=admin -e MYSQL_PASSWORD=Abcd12345 -p 3306:3306 mysql:latest 823b4c91c0d1a8ac39fef0a1bcc911d5253afb19630fbb2b5800372143d439703rd Enter MySQL terminal inside the container
docker exec -it my-mysql mysql -u admin -p

Creted EBS_APP
A simple Flask APP the store student data and show data when view Button clicked , i created this APP
Here is the Repo LInk - https://github.com/DheerenGaud/RDS_APP
Automation flow
for automation i used jenkins pipleine , in the pipeline
1 - i am cloing my image
2 - creating Docker image - here is docer file - https://github.com/DheerenGaud/RDS_APP/blob/main/Dockerfile
3 - then i pused my image to Docker hub - here is my docker hub repo - https://hub.docker.com/repository/docker/dheerengaud/student_db_app/general
4 - then i ssh to EC instance
5 - Deploying the the app on ec2
here is my Jenkinsfile - https://github.com/DheerenGaud/RDS_APP/blob/main/Jenkinsfile
Here some ss Of full work flow
this my all creadentials that store on Jenkins
ec2_ssh_key - is for ssh to EC2 instace (have - keys(.pem))
DB_HOST - ths is endpoinf of EBS - (ex - database-abcd..ap-south-1.rds.amazonaws.com)
DB_USER - its username of EBS DB (defult - admin)

Here is some Builds on jenkins

For confirmation i ssh to my ec2ssh -i mac_login.pem ubuntu@13.204.77.139 docker images
here you can see conatainer is running on port 5000docker ps -a
and i ssh to container , all file are theredocker exec -it ebs_container /bin/bash

Creating new student

View all Studets

Here is my EC2 Instance
