Deploying Spring Boot App on Amazon ECS/AWS Fargate with Application Load Balancer

Application Load Balancer → AWS Fargate

This sample project deploys a Java 21 Spring Boot App on Amazon ECS Fargate with Application Load Balancer to route traffic between two ECS Tasks.

The Amazon ECR The repository of the container image of the Spring Boot Application.
Application Load Balancer receives the HTTP request which routes the traffic to one of the Amazon ECS Tasks.
Amazon ECS Cluster is configured with one service having 2 Tasks. The 2 Tasks runs the Spring Boot application as container. The container image is retrieved from the Amazon Elastic Container Registry. The application uses in-memory database to store the data.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/alb-ecs-java-sam

Deploy

mvn clean packagebash buildsam deploy --guided


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

Delete the stack: sam delete.
Delete the ECR repository: bash delete-ecr-repo.sh.

Created by:

Biswanath Mukherjee

Biswanath Mukherjee

Sr. Solutions Architect working at AWS India.

Follow on LinkedIn