Gitlab CI & Amazon AWS ECS

In my last project, Continous Integration (CI) and Continous Delivery (CD) were required because the web application is updating were frequently and we are developing test-driven. Therefore, I decided to use Gitlab CI as a CI service because it supports us to provide the code quality. After each pushed commit, the test suite is started and if the test did not pass, our code will stop processing (e.g. not released).

With all these features, we ensure that our code will always pass the tests. But the next (and maybe most important) step is to push our code to our server. We decided to use Amazon AWS for hosting our code because it provides us a flexible and scalable infrastructore. In particular, we are using the AWS Elastic Container Service (ECS) because we wrap our software in docker containers.
Now, we had to deliver our code from the Gitlab CI to the AWS infrastructure. Therefore, you can simply create a cluster for our project as well as tasks for the developed different, independent software components. The main workflow should be that after all tests passed in the Gitlab CI, the docker with the to be deployed source code container should be pushed to a registry and after that ECS should be notified about the newer version that a new container instance should be created and replace the old version.

This plan is very abstract, so let`s getting a little bit more concrete:

In our case, we used also the Gitlab CI as the Docker Registry because you can store there also your docker images. In the following text, I will describe how you can deploy your code step by step to ECS:

  1. Run your test-suite in Gitlab CI
  2. Store your docker images on Gitlab
  3. Update the docker image on ECS


2 thoughts on “Gitlab CI & Amazon AWS ECS

  1. Interesting article, hard to find gitlab ci to AWS ECS out there in wild. So I am Curious to know if you are using a tool like ecs-deploy for the deployment to ecs.

    1. Hey Raj,
      thank you for your question. Sorry for the late reply. Currently, I am still working on the third part of the tutorial but I use the command line tool of AWS to push my images to the ECR. After that, my staging environment is updated to the new image and in the end, if all works fine in the staging environment, I deploy it also to the production environment (change image of container and rebuild and restart the containers). Hope this helps.

Leave a Reply

Your email address will not be published. Required fields are marked *