Member-only story
AWS CodePipeline for Amazon ECS, Part 2: A Blue/Green Deployment Type
In this tutorial, I would like to explain to you how to create an AWS CodePipeline for ECS with a Blue/green deployment type.
This is the second part of the tutorial on AWS CodePipeline for ECS. I highly recommend that you read the first part here. In part 2 I focus on how to create the CodePipeline. Here I assume that you already have an ECS cluster, an Elastic Load Balancer with at least one Target Group, an ECR repository with a Docker image, a task definition that uses this image, and an AWS CodeBuild project.
The diagram below shows how the AWS CodePipeline integrates with the AWS ECS with a blue/green deployment type.
1. Source code
The source code for this example you can find here. For CodePipeline to work properly a root directory of a source code of an application has to have 3 files: appspec.yaml, buildspec.yaml and taskdef.json.
The appspec.yaml is very simple and should look like the example below. Just fill up ContainerName and ContainerPort. Both of these configurations you can find in a task definition.