I have an ECS Cluster on which i have configured 3 different Services (let's say svc1, svc2, svc3).
I would like do make sure the tasks/containers of each service are run on EC2 instances that are not running tasks/containers of the other two services.
I have read the documentation about task placement contraints and about task groups and I understood is that when a task created by a service it automatically gets a task group with the same name of the service.
So what I configured on each of my 3 services (in the service itself, not in the task definition) is the following placement constraint:
Type: memberOf Expression: task:group != service:svc2 and task:group != service:svc3
On each service I would exclude the other two.
This configuration doesn't seem to work though as I get two behaviours:
service svc1 was unable to place a task because no container instance met all of its requirements. The closest matching container-instance 3d9d2d497fc9489ab26551475f4d7025 encountered error "MemberOf placement constraint unsatisfied.". For more information, see the Troubleshooting section of the Amazon ECS Developer Guide.
I'm really not understanding how this is supposed to work and if I'm missing something or it's just bad documentation.
From official docs, the way of specifying a negative match is not(task:group == database)
-> in your case it would be not(task:group == service:svcX)
.
Hope it helps!