AWS RDS[Relational Database Service] -
It is a web service running "in the AWS cloud" designed to simplify the setup, operation, and scaling of a relational database for use in applications.
Advantages
Not worry about
- Replication
- Auto backups
- Auto Recovering
- Caching
Hope you have an account in AWS cloud! Else you can create an account in AWS(Its not a rocket science, its very simple).
Amazon RDS is pay as you go.
Storage is billed per gigabyte per month, and I/O is billed per million-request.
Search and open RDS service in AWS as below mentioned snap.
Steps to follow to create a database in RDS.
**
Click create database
Choose Standard create database creation method
Select Engine Type as MySQL.
Amazon Aurora(optimized combined version of postgres and MySQL), MariaDB, PostgreSQL, Oracle, Microsoft SQL Server are the different engines which are available in RDS Service.Select the version which is matching the version that you've used in springboot.
Choose Free tier(Use RDS Free Tier to develop new applications, test existing applications, or gain hands-on experience with Amazon RDS)
Give a name for your DB instance.
Setup the db credentials (username and password for db)
Make the RDS visibility as publicly access mentioned below snap
Keep other things as default and click Create Database
TADAAAH!!! DB CREATED Successfully
Click the demo-db identifier and you can see that an endpoint and the port number 3306 are shown under Connectivity and Security area.
Before testing the connection in MYSQL Workbench you should open the port number 3306 for this demo-db.
If you scroll down you can see two security group roles are present which is mentioned as default under Security Groups section.
Select a SG(Security group) from that who is having CIDR/IP - Inbound as Type. SG acts like a firewall for RDS [Restricting the access], so we have to open the port 3306[Allowing access to request which is coming only from port 3306].
Integrate demo-db [RDS] to our SpringBoot app
Use this configuration in application.properties file:
spring.datasource.url=jdbc:mysql://<Give endpoint as hostname>:3306/schema_name
spring.datasource.username=<_username given during initial setup for RDS>
spring.datasource.password=<password given during initial setup for RDS>
Please check/test connection using MySql WorkBench by configure connection by giving hostname as endpoint which is generated after the db creation in RDS and give credentials which is given during db setup.
Yaaay!!!Now you're successfully configured springboot to RDS.
Now your data will be stored in cloud!!!
Next Part we will discuss how to deploy the fat jar in Elastic BeanStalk.
Top comments (0)