Customers often ask for help with implementing Blue/Green deployments to https://aws.amazon.com/ecs/ using https://aws.amazon.com/codedeploy/. Today, I will discuss those design decisions in detail and how to use https://aws.amazon.com/pt/blogs/developer/cdk-pipelines-continuous-delivery-for-aws-cdk-applications/ to implement a self-mutating pipeline that deploys services to Amazon ECS in cross-account and cross-Region scenarios.
This allows us to implement the following approach: Toolchain stack deploys the pipeline with CodeDeploy deployment action referencing a non-existing CodeDeploy application and deployment group When the pipeline executes, it first deploys the Service stack that creates the related CodeDeploy application and deployment group The next pipeline action executes the CodeDeploy deployment action.
To make this work, you should use the same application name and deployment group name values when creating the CodeDeploy deployment action in the pipeline and when creating the CodeDeploy application and deployment group in the Service stack (where the Amazon ECS infrastructure is deployed). This approach is necessary to avoid a circular dependency error when trying to create the CodeDeploy application and deployment group inside the Service stack and reference these objects to configure the CodeDeploy deployment action inside the pipeline.