Deploying a Spring Boot app to AWS Elastic Beanstalk is relatively easy using the eb cli tool, if you’re prepared to accept some defaults as part of the deploy. It’s probably possible to configure/customize IAM roles, Security Groups etc, but accepting the defaults is an easy way to deploy during development.
To initialize a new Elastic Beanstalk deployment, run in the root of your Spring Boot source folder:
eb init
Before creating the environment and deploying your app, edit the .elasticbeanstalk/config.yml that the previous step creates, to configure the built app jar to be deployed, by adding this section:
deploy:
artifact: target/your-app-jar-0.0.1-SNAPSHOT.jar
To create a single dev/test env with no load balancing:
eb create --single
To tear down the deployed ec2 instance running your Spring Boot app:
eb terminate
Service Port Configuration
By default, Beanstalk services are deployed on port 5000. Since Spring Boot apps are on port 8080 by default, the quickest way to configure Spring Boot to accept incoming requests on port 5000 is to edit the ‘Updates, monitoring and logging’ section and add a new env var for Spring Boot to reconfigure to use port 5000 instead (this is described here)
Added new env var SERVER_PORT=5000:
One Reply to “Deploying a Spring Boot app to AWS Elastic Beanstalk with the eb cli”