- Newest
- Most votes
- Most comments
Hi
The only thing I think you're missing is that the default task group for an ECS service is in fact service:<service name>.
So for your example, you would need to provide the filter as follows:
aws ecs list-container-instances \
--cluster dev \
--filter "task:group == service:workflow"
On top of that, I would also double check that you do indeed have tasks running in that service. Otherwise, you'll see the above give the same empty list as an output.
Once you get a hang of the query languge, anti-affinity can be found using the not keyword as follows:
aws ecs list-container-instances \
--cluster dev \
--filter "not(task:group == service:workflow)"
Additionally, the task group for a single task can be overidden when running the task via the RunTask API. In the case where no task group set with RunTask, the default is family:<task definition family>.
Hope this helps. Let me know if you have any further questions.
Thanks @fortejas-amazon, that was exactly it. Re-reading the documentation it makes perfect sense now.
When you launch a task using the RunTask or StartTask action, you can specify the name of the task group for the task. If you don't specify a task group for the task, the default name is the family name of the task definition (for example, family:my-task-definition).
For tasks launched by the service scheduler, the task group name is the name of the service (for example, service:my-service-name).
I was confused by the examples which show this:
"placementConstraints": [
{
"expression": "task:group == databases",
"type": "memberOf"
}
]
Which I understand now, would be for explicitly named task groups.
Relevant content
- asked 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago