If your goal is Zero Down Time, ECS already comes packaged as so by default, but not in what I'd call Blue/Green deployment, but rather a rolling upgrade. You'll have the ability to control percentage of healthy instances, ensuring no downtime, with ECS draining connections from the old tasks and provisioning new tasks with new versions.
Your application must be able to handle this 'duality' in versions, e.g. on the data layer, UX etc.
If Blue/Green is an essential requirement, you'll have to leverage CodeDeploy and ALB with ECS. Without going into implementation details, here's the highlight of it:
- You have two sets of:
Task Definitions
and Target Groups
(tied to one ALB)
Code Deploy
deploys new task definition, which is tied
to the green Target Group. Leaving blue as is.
- Test your green deployment by configuring a test listener to the new target group.
- When testing is complete, switch all/incremental traffic from blue to green (ALB rules/weighted targets)
- Repeat the same process on the next update, except you'll be going from green to red.
Parts of what I've described are handled by CodeDeploy, but hopefully this gives you an idea of the solution architecture, hence how to automate. ECS B/G.