Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a service on AWS ECS with container overrides?

On AWS ECS you can run a task, or a service.

If you run a task with run_task(**kwargs), you have the option to override some task options, for example the container environment variables, this way you can configure the thing inside the container for example. That's great.

Now, I can't find a way how to do the same with create_service(**kwargs). You can only specify a task, so the created container runs with configuration as specified in the task definition. No way to configure it.

Is there a way how to modify task in a service, or this is not possible with the AWS ECS service?

like image 634
stibi Avatar asked Mar 22 '16 08:03

stibi


1 Answers

This is not possible. If you think how services work, they create X number of replicas of the task. All instances of the task have the same parameters, because the purpose is scaling out the task - they should do the same job. Often the traffic is load-balanced (part of service configuration), so it is undesirable that a user will get different response next time than the previous request due to ending up on a task which is configured differently. So bottom line is - that's by design.

Because parameters are shared, if you need to change a parameter, you create a new definition of the task, and then launch that as a service (or update an existing service).

If you want the tasks to be aware of other tasks (and thus behave differently), for example to write data to different shards of a sharded store, you have to implement that in the task's logic.

like image 98
denismo Avatar answered Oct 30 '22 15:10

denismo