JAVA docker application in ECS

AWS CloudFormation sample that builds and runs a Java8 with Maven application on ECS

JAVA docker application in ECS

JAVA docker application in ECS

This is a tutorial on how to deploy an JAVA application built with Maven in ECS using AWS CloudFormation.

The CloudFormation template is posted on on GitHub and contains all you need to have the stack up and running.

Run the CloudFormation template in the AWS Console

  • Login to the AWS console and browse to the CloudFormation section
  • Select the cloudformation-template.yaml file
  • Before clicking "Create", make sure that you scroll down and tick the “I acknowledge that AWS CloudFormation might create IAM resources” checkbox
  • ...drink coffee...
  • Go to the URL in the output section for the environment that you want to access

Resources created

  • 1 VPC and 2 subnets (with public/private routes)
  • 1 AutoScaling Group
  • 1 Application Load Balancer
  • 1 ECS cluster
  • 1 RDS MySQL DB
  • 1 EFS
  • 1 EC2 bashton instance
  • 1 SNS topic (send monitoring alerts)


The autoscaling groups uses the CpuUtilization alarm to autoscale automatically.

Because of this, you wouldn't have to bother making sure that your hosts can sustain the load.

Data persistency

The stack makes use of AWS' EFS system to ensure that even though any container fails it will have access to any data that was previously being handled by the previous container.

Due to its high-throughput and NFS connectivity mechanisms, it has been successfully used to store data for the (single) MySQL container running for each environment.


Backup is being performed via RDS mecahnisms.

Final notes

Need help implementing this?

Feel free to contact us using this form or via email at .

Share this on LinkedIn

More Articles

Our Certifications

AWS DevOps Engineer AWS Solutions Architect AWS SysOps Administrator Google Certified Administrator Microsoft Certified Professional