CI/CD in AWS Elastic Container Service (ECS)

January 04, 2020 in #ecs #aws #ci/cd | | | Share on Google+

Fully managed container orchestrator on AWS, CI/CD and easy deployment with CloudFormation

Your takeaways from this post

  • Understanding the difference between ECS and Kubernetes
  • Why ECS is still a great choice nowadays
  • How to quickly deploy ECS with CloudFormation (infra as code)
  • CI/CD to ECS: a developer push in Github will automatically deploy the new version of the app

What is ECS?

  • Elastic Container Service (ECS) is the fully managed container orchestration service on AWS cloud. ECS with Fargate let you manage containers without taking care of the underlying infrastructure. Depending on your container load, the infra will scale up or down, be redundant in multiple availability zones.
  • Elastic Kubernetes Service (EKS) is a fully managed Kubernetes service on AWS. We talked about Kubernetes some time ago in this post.

If you plan on running your containers in AWS Cloud, these two services should answer all your needs, but which one to choose?

ECS or EKS(Kubernetes)?

  • Small deployments: prefer ECS due to its seamless deployment and configuration. In fact, ECS is cheaper for few containers as you don't pay for the control plane (master)
  • Large or hybrid deployments: prefer EKS due to stronger customization and improved portability between clouds and on-premise systems.
  • Legacy workloads: if you are transitioning to a containerized environment, plain Kubernetes may be the best choice, as it will allow you to build a dev/test/production environment on-premises, and then move it to the cloud if and when required.

Pricing comparison

Deploy ECS

This setup will deploy a redundant hello world container on ECS Fargate, with automatic CI/CD from AWS.



  • Cloud: AWS
  • ECS: container orchestrator (on 2 availability zones for redundancy)
  • ECR: container registry to store hello image
  • App: a simple hello world in Nodejs (folder hello)
  • CI/CD: CodePipeline to build and deploy the container in ECS
  • Code source: Github
  • Deployment: CloudFormation describe all component to be deployed. One command line will setup the infra and return an url to access the application.

CI/CD flow diagram


A simple git push from a developer in Github will launch the whole CI/CD process. Docker image will build and ECS will update to run that new image without any downtime.

Get the code

Check out the Github repo to deploy the infra.

Another ECS project: a cheap old ghost blog


In this project, I launched the cheapest (<3$ per month) ghost blog container, with a persistent disk (EFS + backup), running on AWS ECS, 1 reserved EC2 instance, CloudFront & Certificate & Healthcheck, all deployed with Terraform. The code is here.


  • If you are using AWS, ECS is simple to use and very well integrated in AWS infrastructure (CodePipeline, Fargate, Cloudwatch).
  • The pricing is really fair for a fully managed container orchestrator. If you use the EC2 model (not fargate), you only pay for the instance, ECS orchestrator is free!
  • It is the perfect choice to run small workload of containers in AWS, if you are sure you will not need later a hybrid solution (on premise, or other cloud).

Thank you for reading :-) See you in the next post!

January 04, 2020 in #ecs #aws #ci/cd | | | Share on Google+