When deploying tasks of a service in an AWS ECS cluster by executing cdk deploy, does the command return before all new instances are spin up and all old instances were drained or does it wait?
I checked the documentation of AWS CDK and AWS CloudFormation. The latter one states:
The command terminates after AWS CloudFormation executes the change set. If you want to view the change set before AWS CloudFormation executes it, use the –no-execute-changeset flag.
It leaves open if the execution of the change set includes spinning up and draining tasks.
2
Answers
No, it does not wait for tasks to spin up.
cdk deploy
finishes when the CloudFormation resources are created.CloudFormation creates the Cluster, Service and TaskDefinitions. Launching the tasks is downstream of this and is managed by ECS.
If circuit breaker is enabled, then it will NOT wait for the tasks to spin up.
However, if the circuit breaker is disabled, cloudformation will attempt to deploy the desired amount of tasks before finishing.
If the tasks fails to deploy, this actually causes the cloudformation deployment to go on for a long period of time before giving up. This use case is discussed here