Search code examples
amazon-web-servicesamazon-ecsaws-cdkaws-fargate

Defining multiple tasks in the same fargate service in cdk


I have a fargate service that has a task definition associated with it. I need to run 20+ containers in that service. Preferably each containers would have its own task (I understand that the ecs service limit is 10 containers per task anyway!). I don't seem to find the right way to do so. I'm defining this infrastructure using AWS CDK in Python.

Trying to define multiple fargate tasks using the same task definition in the same fargate service in CDK


Solution

  • If you need to run multiple copies of a single docker image, then in ECS that is a single task, with a single container in that task. Once you have configured a task definition for that, then you would launch it as an ECS service and set the desired service count to be 20 or whatever number you want. At that point you can also configure auto-scaling to add or remove more tasks (instances of your container) as needed.