The answer is yes, but it's a complicated process. The best way I know is to use CodePipeline for your build automation, and have your build step produce a new taskdef.json
and a new appspec.yml
file as output artifacts.
These are then inputs to the deploy step. Assuming you've set up a CodeDeploy Application, with a Deployment Group linked to a load balancer, you can then have CodeDeploy update your service to use the new task definition.
However, the key to making this work is to have the code that generates the new appspec.yml
find the current revision number of the task definition and add 1 to it.
Without incrementing the revision, it will just stay on the old version of the task def even though it will create the new revision.
I've done this using the SDK, but I imagine you could do it with some cunning CLI scripts and jq
. For example, to find the latest version of the taskdef:
aws ecs list-task-definitions --family-prefix <taskdef-family> --query 'taskDefinitionArns[-1]'
It's not too far from there to incrementing the revision number and building your new appspec.yml
containing the 'next' revision of the taskdef.