echen
echen

Reputation: 2072

AWS Deploy ECS with Updated Image

It appears that one must provide a new full task definition for each service update. Even though most of the time new deployments exclusively consists of updates to one of the underlying docker images

While this is understandable as a core architectural choice. It is quite cumbersome. Is there a command-line option that makes this easier as the full JSON spec for task definitions are quite complex?

Right now the developers needs to provide complex scripts and deployment orchestrations to achieve this relatively routine task in their CI/CD processes

I see attempts at this Here and Here. These solutions do not appear to work in all cases (for example, for Fargate launches)

I know that if the updated image uses the re-use the same tag this problem is made easier, however in dev cultures that values reproducibility and audibility that is simply not an reasonable option

Is there no other option than to leverage both the AWS API & JSON manipulation libraries?

EDIT It appears this project does a fairly good job https://github.com/fabfuel/ecs-deploy

Upvotes: 3

Views: 2330

Answers (2)

jwillker
jwillker

Reputation: 1035

Use https://github.com/fabfuel/ecs-deploy.

If you want to update only the tag of an existent task:

ecs deploy <CLUSTER NAME> <SERVICE NAME> --region <REGION NAME> --tag <NEW TAG>

e.g. ecs deploy default web-service --region us-east-1 --tag v2.0

In your ci/cd you use git hash: Using git rev-parse HEAD, will return a hash like: d63c16cd4d0c9a30524c682fe4e7d417faae98c9

docker build -t image-name:$(git rev-parse HEAD) .
docker push image-name:$(git rev-parse HEAD)

And use the same tag on task:

ecs deploy default web-service --region us-east-1 --tag $(git rev-parse HEAD)

Upvotes: 0

echen
echen

Reputation: 2072

I found a few approaches

  1. As mentioned in my comment, use ecs-deploy script per the Github link

  2. Create a task definition via the --generate-cli-skeleton option on awscli. Fill out all details except for execution-rule-arn, task-role-arn, image

These cannot be filled out because they will change per commit or per environment you want to deploy to

Commit this skeleton to git, so it is part of your workspace on the CI

Then use a JSON traversing/parsing library or utility such as https://jqplay.org/ to replace at build time on the CI the roleArn and image name

Upvotes: 1

Related Questions