This article is about installing a Spring Boot Application on AWS using this technology stack: EC2 to run the Java program systemctl to control start/stop/restart the application Configuration of the Spring Boot application using environment variables We start from the assumption that a jar file has been created and is available on AWS S3 or some other artifact repository. Step 1: Create the EC2 Instance Prerequisites: AWS account 1 VPC - dev-vpc 1 subnet - dev-apps-subnet I created an EC2 instance of size small with an Amazon Linux image. In that instance, I created a folder for the application and copied the jar file genova-1.0.jar containing the Spring Boot application to that folder. Step 2: Configure the Process to Run the Java Application SystemD is a Linux facility that automatically starts, restarts, and stops processes. In this case, it consists of a file in /etc/systemd/system: Also, it is possible to configure other environment variables in the file genova.conf: JAVA_HO...
Beanstalk is an AWS-managed service that allows applications to run containerized in AWS. I am using Elastic Beanstalk (EB) to deploy quickly developed applications when the emphasis is on time-to-market rather than all the features of an enterprise application. For the purpose of this post, I will use the application called Genova as an example. It is a web application that exposes HTML and JSON content. Step 1 - Create a Spring Profile for AWS Beanstalk The configuration of Spring Boot application is applications-<profile>.yml files that are in the src/main/resources folder. By default, an EB deployment listens to the port 5000. For this reason I am creating the file application-eb.yaml with the following content: server: port: 5000 Step2 - Build the Spring Boot Application Using maven to create the Spring Boot jar file: mvn clean package -DskipTests This command creates a file with the name genova-1.0.0-SNAPSHOT.jar in the target folder. Step 3 -...