Deploying Spring Boot App on Elastic Beanstalk

Just trying out some new AWS services that I have not worked with before. From the AWS docs it sounded like Elastic Beanstalk (EBS) is a pretty easy service to use, and indeed it is. I had written a trivial Spring Boot app that exposes a couple of REST endpoints and it seemed like a good app to start with.

First, I prepared the jar for deployment using:


mvn package

Then, I just went through the EBS wizard accepting most of the defaults, uploaded the jar, and started the app. The dashboard is quite useful with health status, event logs, and stats.

Hitting the app in my browser got a “502 Bad Gateway”. Digging to understand the structure behind the Beanstalk deployment, I found the following:

  • Nginx is used for load balancing
  • The load balancer listens on port 80
  • It forwards requests locally to port 5000

So, the simplest solution was to change the Spring application.properties to include:


server.port=5000

And the application worked! I am yet to experiment with the full breadth of features it provides, but so far Beanstalk is pretty impressive.

(P.S. This post helped verify my solution).

beanstalk

Leave a comment