arminc / terraform-ecs

AWS ECS terraform module
MIT License
804 stars 374 forks source link

Suggestion on running on every host #11

Closed nathanpeck closed 6 years ago

nathanpeck commented 7 years ago

I have a suggestion with regard to this challenge of running one task per host on boot.

Another approach some use is to create a service with the deployment constraint distinctInstance to tell ECS to only place one task per instance, then you can either go the easy route and set the service desired count to a really high arbitrary number and forget it, or else use a Lambda function to keep the service desired count in sync with the number of instances in the cluster's autoscaling group. This will cause ECS to always start one of that container on each instance and ECS will restart the tasks as well as if they stop.

Hope this helps!

arminc commented 7 years ago

Thanks for the suggestion. That is indeed an option I still have to try out and add. I fixed the titel on the issue #2

Sometimes you want your 'system' container like fluentd for logging to run before any other container runs by ECS. This is because you might loose logging. Although not that big of an issue I am not sure how to fix that with suggested approach.

For the tings like metrics containers etc.. it is fine.

But it would be awesome to have the "blox serverless" https://github.com/blox/blox/issues/199 :)

nathanpeck commented 7 years ago

Gotcha. When you try it out feel free to reach out with any feedback you might have on challenges. I would love to gather your feedback so I can get it to the ECS team to help improve any use case (such as one per host) that you find challenging to implement. :)

arminc commented 6 years ago

I tried the "distinctInstance" and it works fine, but still not in favour of it :) Closing the issue and waiting the status of blox beeing serverless as mentioned in #2