Deploying a Java Code using AWS EC2
In this post, we will see how to deploy the JAR on a EC2 instance with Auto Scaling Group with Load Balancer.
We can do the same using AWS Code Deploy with orchestration using AWS Code Pipeline. We are taking a different path.
In the previous post, https://rsinfomindss.blogspot.com/2026/04/aws-codebuild.html
Once the build is stored in the S3. We have to perform the below steps in a EC2 instance to run the code.
- 1)
Download Java.
- 2)
Create a folder for the application.
- 3)
Download the JAR from S3.
- 4)
Start the JAR.
Finally, update the "User Data". EC2 has a feature called "User Data" which can be used as boot/startup script.
Our launch template is ready.
Let's create a Auto Scaling Group from the above Launch Template with a Load Balancer.
We are done and we could see our EC2 instances are HEALTHY.
And, we could access the application using Load Balancer DNS.
Whenever a new code is pushed, all we need to do it replace the EC2 instance by stopping/terminate them. So, that ASG creates a new instance with new JAR.

Comments
Post a Comment