Re-use existing task def with latest version
We are managing our task def in Terraform. We do not want ecs-deploy to create/register a new taskdef. Instead we just want it to update the service with latest version of existing taskdef.
Is there a way?
Used below command but no luck since it worked as expected -
ecs deploy my-cluster my-service --task my-task --timeout 420
Hi @vivekyad4v
was there something wrong with the end-result after you ran the mentioned command, except for there was a new revision created?
The current mechanism is, that ecs-deploy creates a new task-definition (with optional adjustments) and updates the services accordingly to use this task-def revision.
Do I understand correctly, that you want ecs-deploy to identify the newest revision of a task family and update the service with this revision?
This is your desired workflow, right?
- run terraform to create a new task definition (revision)
- run ecs-deploy "ecs use-newest-revision my-cluster my-service"
Best Fabian
Not directly related, but as you use Terraform, this might be useful: https://twitter.com/fabfuel/status/1178249588353982464?s=20
Yes, as you suggested, below is the desired workflow -
- run terraform to create a new task definition (revision)
- run ecs-deploy "ecs use-newest-revision my-cluster my-service"
Why we need this is because we manage all SSM paramters, Taskdefs, Services, CICD etc in Terraform itself. Post a change, the latest taskdef ARN is passed to AWS codebuild project as a parameter which in turn is used to deploy the ECS service. The problem happens when ecs-deploy creates the new taskdef which Terraform is unaware of and creates a conflict. We have a workaround as to let Terraform use the latest taskdef by defining a data source. However, it would be great if we can get this feature in this super awesome tool. I am pretty sure there can be similar use cases where people just want to deploy the lastest taskdef since it's managed by some other tool.
This would be super cool - $ ecs use-newest-revision my-cluster my-service
@vivekyad4v the documentation already mentioned a solution:
https://github.com/fabfuel/ecs-deploy#deploy-a-custom-task-definition
Deploy a custom task definition Or just a task family name. It this case, the most recent revision is used:
$ ecs deploy my-cluster my-service --task my-task
This is still an issue, read just below:
ecs will still create a new task definition, which then is used in the service.
This is problematic for my setup. I would just add an optional parameter to disable that feature and just use the given task definition.
If you just want to update the service with the current task definition, couldn't you simply use the awscli?
aws ecs \
update-service \
--cluster <name> \
--service <name> \
--force-new-deployment
@Sytten could you expand on your downvote? Why would that not be a viable option ?
I mean it's not bad advice per se but it is not what the issue is about. It is about updating a service to the latest task definition version without creating a new one. So say I have a task definition my-task where the version 0 is assigned to the service, then I create a new version in terraform or somewhere else (version 1). If I do a --force-new-deployment it just creates new pods with the same version 0, where what we want is that the service be updated to version 1 without this tool creating a version 2 :)
Hi folks,
could you please check, if this solves your issue? Instead of --force-new-deployment you can provide the task definition family (or name) without a revision, ECS will then pick the newest revision automatically:
aws ecs \
update-service \
--cluster <name> \
--service <name> \
--task-definition <task definition family>
For example:
aws ecs update-service --cluster foobar --service nginx --task-definition nginx
From the AWS CLI help:
--task-definition (string) The family and revision (family:revision ) or full ARN of the task definition to run in your service. If a revision is not specified, the latest ACTIVE revision is used.
Best Fabian