3pillarlabs/spring-boot-ecs-starter

Name: spring-boot-ecs-starter

Owner: 3Pillar Global Open Source

Description: A starter project for Spring Boot microservices to deploy on ECS

Created: 2018-03-23 07:17:41.0

Updated: 2018-04-02 14:34:21.0

Pushed: 2018-04-02 14:34:20.0

Homepage: null

Size: 145

Language: Java

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

spring-boot-ecs-starter

A starter project to deploy Spring Boot microservices in Amazon ECS Cluster

This starter kit includes the following artifacts:

springbootservice1: This is a Java Spring Boot sample microservice

springbootservice2: This is another sample Java Spring Boot microservice

ECS-CF-springboot-ALB-single-service: Use this YML template file to launch CloadFormation stack for a single service (springbootservice1)

ECS-CF-springboot-ALB-multiple-services: This YML template launches CloadFormation stack for a multiple services (springbootservice1 & springbootservice2)

ResourcesToBeCreated-single-service: This diagram shows the resources that will be created by ECS-CF-springboot-ALB-single-service CloudFormation stack

ResourcesToBeCreated-multiple-services: This diagram shows the resources that will be created by ECS-CF-springboot-ALB-multiple-services CloudFormation stack

Steps to build the microservice and launch the ECS Cluster

1. Build your applciation jar: “gradle clean build” from root directory of the applications springbootservice1 & springbootservice2

2. Build springbootservice1 Docker image : “docker build -t springbootservice1 .” from root directory

2. Build springbootservice2 Docker image : “docker build -t springbootservice2 .” from root directory

3. Host the Docker image: Host this docker image to Docker hub or ECR

4. Launch ECS Cluster from CloudFormation: Use ECS-CF-springboot-ALB-single-service to launch the cluster with springbootservice1 only and if you want to launch both the services then use ECS-CF-springboot-ALB-multiple-services You can either save the YML files to an s3 bucket and refer during launching the CF stack or copy its content and paste in designer.

These template use image(s) hosted on AWS ECR, you can use your own image hosted on ECR or Docker hub. To do so, search for “image” in the template and replace it with your image.

When you will launch the CloudFormation stack, provide some values when asked like Cluster name, no of minum & maximum number of instances in ECS Cluster, VPC, Subnets….

5. Test the service(s): Wait untill Stack status is shown as Complete

Check in Load Balancers list under EC2 Service, you will see a newly created ALB with name ECSALB. Copy the NDS (A Record) of the ALB and test the service(s) as mentioned below and replace {ECSALB} with ALB DNS:

{ECSALB}/service1 You will see message “Welcome to the 3Pilar Global springboot service sample”

{ECSALB}/service1/hello You will see message “Hello, how are you today…”

{ECSALB}/service2 You will see message “Welcome to the 3Pilar Global springboot service2 sample”

{ECSALB}/service2/hello You will see message “Hello from service2…”

When you call your multiple services using single ALB as mentioned in above, it is called path based routing when the ALB determines that which Target Group wikk service a request like /service1 or /service2

Please check other resources created by CloudFormation.

6. Delete the stack Once done, go and check the box again CloudFormation Stack and from Actions choose Delete Stack, this will delete all the resources created by the Stack.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.