Recently, I worked on a PoC to create an automated build pipeline for a springboot rest api in elastic beanstalk. Based on prior knowledge related to the use of Amazon EBS, this was expected to be a trivial tasks. Turns out that without a solid knowledge on setting up and managing configurations for AWS resources, doing this can be challenging.
There are a host of pages and videos explaining how to deploy spring/springboot applications to elastic beanstalk. however, I was not lucky enough to find one explaining details of the underlying computing resource for this configuration.
For this post, I am focusing on the configuration required to deploy a java application on elastic bean stalk, using Amazon EBS CLI. This can also be done with AWSCLI, though, EBS CLI is tailored to meet our needs.
Infrastructure Diagram
To run java applications with EBS, we can use several configurations. Deploying an application that runs on scalable EC2 instances is common, hence is used in this guide.
Requirements
You'll obviously need to have an AWS account with the required access level to AWS console.
If you have not done so, install AWSCLI and configure your credentials.
You can create named profiles with your aws credentials and configuration using this guide.
Install EBS CLI
Follow this tutorial to create and deploy a simple springboot application with AWS Elastic Beanstalk. Remember to select "create a new SSH public, private key pair" when prompted to.
Implementation Notes
I noticed that the eb create
command fails when the following line is added:
deploy:
artifact: target/spring-boot-bootstrap-eb.jar
If you get the following error message: ERROR: NotFoundError - Application Version does not exist locally (target/spring-boot-bootstrap-eb.jar). Try uploading the Application Version again.
Remove the deploy artifact configuration and use the following command to create your environment:
$ eb create --source target/spring-boot-bootstrap-eb.jar --$ version spring-boot-bootstrap-eb
Similarly run the following command to deploy
$ eb deploy --version spring-boot-bootstrap-eb
You can review the CLI documentation or use eb command_name --help
to view usage of different commands.
SSH to your EC2 Instance
Now you're all set to go!
$ eb ssh
$ cd /var/app/current
$ java -jar application.jar
You can run regular commands as you'd do in a local environment. This can be useful for troubleshooting application instances.
Top comments (0)