Deploy Spring Boot MySQL CRUD REST API Application on AWS | Elastic Beanstalk | AWS RDS

In the previous tutorial, we have seen how to build CRUD REST APIs using Spring boot, JPA, Hibernate, and MySQL database. In this tutorial, we will learn how to deploy the same Spring Boot MySQL CRUD REST API Application on AWS using Elastic Beanstalk and AWS RDS service.

We use AWS RDS (Amazon Relational Database Service) to deploy MySQL database on AWS cloud.

Amazon Relational Database Service (Amazon RDS) makes it easy to set up, operate, and scale a relational database in the cloud. It provides cost-efficient and resizable capacity while automating time-consuming administration tasks such as hardware provisioning, database setup, patching, and backups. It frees you to focus on your applications so you can give them the fast performance, high availability, security, and compatibility they need.

Read more about RDS at https://aws.amazon.com/rds/

To understand more about this tutorial, I have created a YouTube video on the same topic so I highly recommend you to watch the YouTube video. (YouTube video present at end of this tutorial)

Workflow

Deploying Spring Boot MySQL CRUD REST API Application on AWS using Elastic Beanstalk
So far we have seen how to deploy the Spring boot app on local and connect to the local MySQL database.

In this tutorial, we will learn how to deploy the Spring boot app on AWS cloud and connect to the MySQL database which is configured on AWS RDS.

Video

Development Process

  1. Sign in to AWS Console
  2. Set up MySQL database in AWS cloud using AWS RDS
  3. Connect to MySQL database with MySQL workbench to verify the connectivity
  4. Clone Spring boot application source code from GitHub
  5. Update application.properties file to change Database MySQL URL property
  6. Package spring boot application as JAR File
  7. Deploy Spring boot JRA file on AWS using Elastic beanstalk service
  8. Test REST APIs using Postman client

1. Sign in to AWS Console

Before login to the AWS console, make sure that you will create AWS free developer account or signup at https://portal.aws.amazon.com/billing/signup.

Once you complete the Signup then Sign in to the AWS console at https://signin.aws.amazon.com/signin

2. Set up MySQL database in AWS cloud using AWS RDS

This step explained in below YouTube video.

3. Connect to MySQL database with MySQL workbench to verify the connectivity

This step explained in below YouTube video.

4. Clone Spring boot application source code from GitHub

5. Update application.properties file to change Database MySQL URL property

This step explained in below YouTube video.
spring.datasource.url = jdbc:mysql://javaguides.ccbtqawd66uq.us-east-2.rds.amazonaws.com:3306/usersDB?useSSL=false
spring.datasource.username = root
spring.datasource.password = password


## Hibernate Properties
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect

# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto = update

server.port=5000

6. Package spring boot application as JAR File

=> mvn clean install

7. Deploy Spring boot JRA file on AWS using Elastic beanstalk service

This step explained in below YouTube video.

8. Test REST APIs using Postman client

This step explained in below YouTube video.

YouTube Video

In this video tutorial, we will learn how to deploy step by step Spring Boot MySQL CRUD REST API Application on AWS using Elastic Beanstalk and AWS RDS service.

Comments