Exploration into ECS (Elastic Container Service) -- Part I - Night1

After reviewing multiple articles and possible options to take a containerized application and deploy it to AWS, I decided upon the general approach of Spring-Boot, Docker and AWS ECS.

So the first task was going to be to come up with a reasonable sample project that represents a reasonable microservice.


  • JDK 8
  • Git (As of writing was using v2.14.3)
  • STS (As of writing was using v3.9.2)
  • Maven (As of writing was using v3.5.2)
  • Python (As of writing was using v3.6)
  • Docker for Mac (As of writing was using (Community Edition)

Get the example project

I found a retrofit of the traditional PetClinic and decided to use it for my explorations: https://github.com/aws-samples/amazon-ecs-java-microservices.

Hopefully you have used git before and you already have a local repository. If you don't, please read up on how to install a git client and become familiar with local git repositories.

Clone the project repository to your local repo. Change directories to where you want the project to be cloned (your root for git repository)

$ git clone https://github.com/aws-samples/amazon-ecs-java-microservices.git

This will result in a project amazon-ecs-java-microservices now being present in your local git folder.

I now moved on to Part 1 of the Sample Pet Clinic project. https://github.com/aws-samples/amazon-ecs-java-microservices/tree/master/1_ECS_Java_Spring_PetClinic.

The two prerequisites for Part 1 were described as Maven and AWS CLI. I already had maven (v3.5.2) installed on my Mac. I did not have AWS CLI installed on my Mac, despite already having an AWS account.

Install AWS CLI with Python pip (3.x)

$ pip3 install awscli --upgrade --user

Following the Sample Pet Clinic Part 1 documentation, they indicate to review the Dockerfile and maven pom file. I prefer to do this within my IDE so I started up STS and imported that project as a maven project. Launch STS and then go to File --> Import. In the dialog select the Maven node and then item "Existing Maven Projects" and click "Next". Browse to the root of the git project <your_root_path_to_git>/amazon-ecs-java-microservices/1_ECS_Java_Spring_PetClinic. The maven pom.xml file should already be selected for you and you can click "Finish" to complete the export.

Now you can review the various files from within your IDE.

You will see that they indicate you can run their python setup script and

This setup script will create an ECR repository, load balancer, compile, build your project, upload the image to the ECR, deploy your infrastructure, and deploy the image into your infrastructure.

It does everything for you. You probably want to spend some considerable time reviewing the script and see what is going on. You can even install PyDev from the Eclipse Marketplace (Help --> Eclipse Marketplace) if you want a more powerful python editor within STS than just a plain old text editor. You will also need to configure python within STS, but you will be prompted once you open a python script with PyDev. You can use the Advanced Auto Configuration. It will find python versions installed on your system and allow you to select which version to configure within PyDev on STS.

As you start reviewing the file you will notice that python is utilizing AWS CloudFormation for defining the AWS stack that will be created. You should probably spend some time reviewing the ecs-cluster.cf file as well. It is located in the root of the project. In the same vein of a more powerful editor to review the file, you may want to install the AWS toolkit for Eclipse. It includes many components and one of them is a Cloudformation template editor. Included Components in AWS Toolkit for Eclipse:

  • The AWS SDK for Java is included and managed by Maven when you create a new AWS project using the AWS Toolkit for Eclipse
  • AWS Explorer, an interface to Amazon Web Services that allows you to manage your AWS resources from within the Eclipse environment.
  • AWS Lambda Java project and Serverless Application Model (SAM) project blueprint creation, deployment and debugging
  • AWS CodeCommit repository cloning
  • Integration with AWS CodeStar
  • AWS Elastic Beanstalk deployment and debugging
  • An AWS CloudFormation template editor
  • Support for multiple AWS accounts

The AWS documentation covers the installation of the Eclipse toolkit nicely https://docs.aws.amazon.com/toolkit-for-eclipse/v1/user-guide/setup-install.html. This will work fine within STS, as STS is just an extension of Eclipse.

Spend some time reviewing the Cloud Formation Template. I really like the Outline feature supplied by the editor within Eclipse as it will provide a tree structure of all the resources, mappings, outputs, etc. that are defined for the AWS stack.

The next step will be to go through Part 1 of the Sample Pet Clinic project build and deployment to see the experience of getting it up and running. Stay tuned for Night 2.

Links to other Nights
Night 2