Spring Boot Application Connect To AWS-RDS



Most of the developers develop their spring boot  project using local database(MySQL). It's easy and efficient.But when developers develop spring boot project with team, then they have to put their relational database on one place.Also when your project is going to production mode, you have to put your relational database on online servers.For this problem has many  solutions.But today I show how put your relational database on AWS RDS.First of all you have to create AWS account if you haven't AWS account yet.You can create AWS Free Tier account and it will not charge for one year.


Now let's create our relational database on AWS.There are few steps.
1. Firstly go to the RDS services.

2. Click the 'Create database' button.After that choose the 'standard create' option.You can choose 'Easy create' option but there are some configuration we have to do.Because of this we choose the standard create option.

3. Then select database engine as MYSQL.Also you can select database version.


4.This selection is most important selection.Because some of the beginners select 'production' or 'Dev/Test' and it will charge your account.Our goal is to create free db server so choose the 'Free Tier' option.


5.Then give name for the database instance. Also master user name for your database instance.Default mater user name is 'admin'. You can change default master username if you want.After that you have to give password for access the db instance.There two methods.you can select 'Auto generate a password' or give you own password.I put my own password.


6. Keep DB instance size , Storage & Availability and durability as it is. Because we use Free Tier RDS.Then go to connectivity section and click the Additional Connectivity Configuration.Your database want to access in your local machine because of this select the Publicly accessible as YES.Then create a new VPC security group.


Now create your first database instance on AWS.Go to database dashboard and look your database created or not.




Our AWS RDS setup is done.Then go to your local machine and open the MYSQL Workbench and create new connection.Give connection host name as your aws rds end point url.


And give port as 3306 , username as admin and give your aws rds password.Now test the connection.

Then you can see below message,

Then access aws database instance using MYSQL workbench and create your database.
Now open your spring boot project.Go to the application.properties file and set datasource url as your aws database endpoint url with your created database name.

Now all the process done and work with your online database.

Comments

Post a Comment