Skip to content

Automatically deploy to ECS (Amazon Container Service)

Problem to solve

In issue #31167 (closed), we provided an image that create containers running aws commands. This issue here is an attempt to define the next step: referencing an image into a AWS ECS task definition.

You can read up more about task definitions on the AWS docs here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definitions.html.

Intended users

Further details

In a nutshell, a task definition is a JSON file that holds all the information related to the container(s) running the user information. It's about specifying resources (CPU, RAM usage), environment variables, etc. Here's the JSON file representing the task definition I created recently. This file also specifies the location of the Docker image to be instantiated onto the EC2 containers managed by an ECS cluster. This last aspect is what we're going to focus on in this issue.

Proposal

After a user pushes an image to, say, the GitLab registry, they should be able to update an existing task definition so that this JSON file points to the new version of the user's image.

update_task_definition:
  stage: deploy
  image: registry.gitlab.com/cloud-deploy/aws:1.0.0
  cloud:
    task-definition:
      image: registry.gitlab.com/ebaque/rails-docker-project/image:v1.0.0
      container-name: web

If this task definition is already used by an AWS ECS service, then this service may need to be updated too (TBC)

Then, using another 'deploy` stage task, a user should be able to trigger a new deployment, which will update the EC2 container(s) with the recently pushed Docker image.

deploy_to_AWS:
  stage: deploy
  image: registry.gitlab.com/cloud-deploy/aws:1.0.0
  cloud:
    deploy:      
      service: my-service
      cluster: my-cluster

Abstract

deploy_to_AWS:
  stage: deploy
  image: registry.gitlab.com/cloud-deploy/aws:**SHA256**
  image_config: #think of a better name
    deploy:      
      service: my-service
      cluster: my-cluster

Permissions and Security

Documentation

Availability & Testing

What does success look like, and how can we measure that?

What is the type of buyer?

Links

Edited by Thao Yeager