Skip to content

// diagrams › aws

Blue/green deployments to Amazon ECS on Fargate with CodePipeline and CodeDeploy

A full CI/CD pipeline for blue/green releases to Amazon ECS on Fargate: CodePipeline, CodeBuild, CloudFormation and CodeDeploy, the workarounds it needs, and when ECS's built-in option is better.

Opens a copy in the editor, in a new tab, ready to change. No account needed.

ECS blue/green deployment pipeline diagram: a merge triggers CodePipeline, CodeBuild pushes an image to ECR, CloudFormation deploys the stacks, CodeDeploy creates a green Fargate task set beside blue, runs a test hook, then shifts the ALB's production traffic.

What’s in this diagram

services and parts

  • Developer
  • Users
  • Source repo (CodeCommit or GitHub)
  • Build, test, scan, push image
  • Container registry (ECR)
  • Nested stacks: ECS, ALB, CodeDeploy
  • Write appspec.yml and taskdef.json
  • CodeDeploy blue/green
  • ALB: production and test listeners
  • Blue task set (current)
  • Green task set (new)
  • Test hook (AfterAllowTestTraffic)
  • Pipeline artifacts

groups

  • AWS Cloud
  • Region
  • CodePipeline
  • VPC
  • Public subnets
  • Private subnets
  • ECS service on Fargate (deployment controller: CodeDeploy)

Key points

  • Blue/green buys an instant rollback: the old tasks keep running until the new ones have proved themselves.
  • The ECS service's deployment controller must be CodeDeploy for this pipeline, or CloudFormation and CodeDeploy fight over the task definition.
  • Test the green tasks on a test listener before any user reaches them.
  • Since July 2025, ECS also has built-in blue/green. For a new service, compare it before building this.

The whole story, step by step: ECS blue/green deployment pipeline with CodeDeploy.

Your diagram is one sentence away.

Start drawing, free

No account needed to start.