Does AWS CDK provide constructs to deploy ECS applications?

Viewed 1901

We generally use BlueGreen & Rolling deployment strategy,

for docker containers in ECS container instances, to get deployed & updated.


Ansible ECS modules allow implement such deployment strategies with below modules:

https://docs.ansible.com/ansible/latest/modules/ecs_taskdefinition_module.html

https://docs.ansible.com/ansible/latest/modules/ecs_task_module.html

https://docs.ansible.com/ansible/latest/modules/ecs_service_module.html


Does AWS CDK provide such constructs for implementing deployment strategies?

3 Answers

CDK supports higher level constructs for ECS called "ECS patterns". One of them is ApplicationLoadBalancedFargateService which allows you to define an ECS Fargate service behind an Application Load Balancer. Rolling update is supported out of the box in this case. You simply run cdk deploy with a newer Docker image and ECS will take care of the deployment. It will:

  1. Start a new task with the new Docker image.
  2. Wait for several successful health checks of the new deployment.
  3. Start sending new traffic to the new task, while letting the existing connections gracefully finish on the old task.
  4. Once all old connections are done, ECS will automatically stop the old task.

If your new task does not start or is not healthy, ECS will keep running the original task.

Regarding Blue-Green deployment I think it's yet to be supported in CloudFormation. Once that's done, it can be implemented in CDK. If you can live without BlueGreen as IaC, you can define your CodeDeploy manually.

Related