terraformamazon-ecshealth-check

Terraform depends_on needs to wait for an ecs container to start AND BE HEALTHY before it continues


Using terraform there is a depends_on capability for any resource type, including an ECS task-group.

ECS tasks can have a z-pages style "Health Check" behavior, when the task starts it must successfully return (usually) an HTTP 200 OK and it will be marked healthy.

Is there a mechanism where the depends_on behavior will wait/delay until there is at least one healthy task. I think right now the depends_on behavior waits until the ECS task is created, but not provisioned or running.

This would be useful in situations such as:


Solution

  • You can set the wait_for_steady_state = true attribute on the ECS service Terraform definition, to get Terraform to wait for the service to be stable.