In this article, we will see the steps to deploy Spring Boot to AWS using Beanstalk. At Bobcares, with our AWS Support Services, we can handle your AWS issues.
How To Deploy Spring Boot To AWS Using AWS Beanstalk?
Spring Boot provides a quick and simple way to create Spring Framework-based apps that are suitable for production. To achieve this, the majority of libraries commonly used with the Spring Framework are packed with auto-setup modules in Spring Boot.
The steps to deploy Spring Boot to AWS using AWS Beanstalk considering we already have a working Spring Boot application are as follows:
- Construct the jar file
- Open Elastic Beanstalk after logging in to the AWS Management Console
- Develop an application
- Modify the application’s port
- Test Spring Boot Application Deployment on Elastic Beanstalk
Construct The Jar File
As we have a working Spring Boot application, we must now prepare the final jar file and keep it on hand in a folder. The jar file is later required for the deployment. To package the application as a fat jar, run the maven build.
mvn clean install
Access Elastic Beanstalk
Log in to AWS Management Console and open the Elastic Beanstalk service (Services >> Compute >> Elastic Beanstalk) to deploy the jar file.
Develop An Application
On the Elastic Beanstalk loading page, click on the “Create Application” button. Then on the new page, enter the application name. Keep scrolling down and enter the below information.
Platform : Java
Platform branch: Corretto 8
Platform version: Best to choose recommended one
After that click on the “Upload your code” option. Now click on “Choose file” and upload the jar file created in Step 1. After the uploading of the jar is successful, click on “Create application”.
Finally, Elastic Beanstalk starts setting up the application environment. we can see a log of the background activity on the dashboard. It may take a few minutes for resource provisioning to finish the setup process.
Once the resource provision completes, we may see the application health marked as Severe. To fix it, click the “Causes” option. We will see 5XX errors. By default, Elastic Beanstalk offers an EC2 instance running Nginx as a reverse proxy and listening on port 80. Also, by default, Nginx routes the request to the program that is open on internal port 5000. So, we need to make sure that port 5000 is used by our Spring Boot deployment using the AWS Beanstalk application.
Modify The Application Port
- On the left-hand side project menu, Click on Configuration.
- On the loading page, we can see multiple categories. Environment variables belong to the Software category. So click the edit “Software” category.
- Now click “Edit” and scroll down to the section “Environment properties”.
- Add a property with the name SERVER_PORT and Value 5000.
- Finally, click on the “Apply” option.
Once done, the application health updates as green.
Test The Spring Boot Application
We have to now click on the application endpoint at the top of the page. Now the application loads successfully.
How To Update The Spring Boot App?
Go ahead with the deploy spring boot to AWS beanstalk and make changes to the app and redeploy them if we want to personalize it. Following are the steps:
- Return to IDE and make the changes.
- Get the jar ready and have it handy.
- To upload the jar file, click Upload and Deploy. A restart of the application with the fresh jar will take some time.
- Finally, hit the endpoint when the update has been completed to verify the changes.
[Searching for an answer to another query? We are just a click away.]
Conclusion
In this article, we provides the steps from our Tech team to deploy the Spring Boot to AWS using AWS Beanstalk.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
var google_conversion_label = "owonCMyG5nEQ0aD71QM";
0 Comments