Create an Amazon ECS blue/green deployment through Amazon CloudFormation - Amazon CodeDeploy
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.

Create an Amazon ECS blue/green deployment through Amazon CloudFormation

You can use Amazon CloudFormation to manage Amazon ECS blue/green deployments through CodeDeploy. You generate your deployment by defining your green and blue resources and specifying the traffic routing and stabilization settings to use in Amazon CloudFormation. This topic covers the differences between Amazon ECS blue/green deployments that are managed by CodeDeploy and deployments that are managed by Amazon CloudFormation.

For step-by-step instructions on using Amazon CloudFormation to manage your Amazon ECS blue/green deployments, see Automate ECS blue/green deployments through CodeDeploy using Amazon CloudFormation in the Amazon CloudFormation User Guide.

Note

Managing Amazon ECS blue/green deployments with Amazon CloudFormation is not available in the Asia Pacific (Osaka) region.

Differences between Amazon ECS blue/green deployments through CodeDeploy and Amazon CloudFormation

The Amazon CloudFormation stack template models Amazon ECS task-related resources and infrastructure, and also the configuration options for deployments. So there are differences between the standard Amazon ECS blue/green deployments and blue/green deployments that are created through Amazon CloudFormation.

Unlike standard Amazon ECS blue/green deployments, you don't model or manually create the following:

  • You don't create an Amazon CodeDeploy application by specifying a name that uniquely represents what you want to deploy.

  • You don't create an Amazon CodeDeploy deployment group.

  • You don't specify an application specification file (AppSpec file). The information normally managed with the AppSpec file, such as the weighted configuration options or lifecycle events, is managed by the AWS::CodeDeploy::BlueGreen hook.

This table summarizes the differences in the high-level workflow between deployment types.

Function Standard blue/green deployments Blue/green deployments through Amazon CloudFormation
Specify the Amazon ECS cluster, Amazon ECS service, Application Load Balancer or Network Load Balancer, Production listener, test listener, and two target groups. Create a CodeDeploy deployment group that specifies these resources. Create an Amazon CloudFormation template to model these resources.
Specify the change to be deployed. Create a CodeDeploy application. Create an Amazon CloudFormation template that specifies the container image.
Specify the Amazon ECS task definition, container name, and container port. Create an AppSpec file that specifies these resources. Create an Amazon CloudFormation template to model these resources.
Specify the deployment traffic shifting options and lifecycle event hooks. Create an AppSpec file that specifies these options. Create an Amazon CloudFormation template that uses the AWS::CodeDeploy::BlueGreen hook parameters to specify these options.

CloudWatch alarms.

Create a CloudWatch alarm that triggers a rollback.

Configure a CloudWatch alarm at the Amazon CloudFormation stack level that triggers a rollback.

Rollback/redeployment. Specify rollback and redeployment options. Cancel the stack update in Amazon CloudFormation.

Monitoring Amazon ECS blue/green deployments through Amazon CloudFormation

You can monitor blue/green deployments through Amazon CloudFormation and CodeDeploy. For information about monitoring through Amazon CloudFormation, see Monitoring blue/green events in Amazon CloudFormation in the Amazon CloudFormation User Guide.

To view deployment status of blue/green deployments in CodeDeploy

  1. Sign in to the Amazon Web Services Management Console and open the CodeDeploy console at https://console.amazonaws.cn/codedeploy.

    Note

    Sign in with the same account or IAM user information that you used in Getting started with CodeDeploy.

  2. In Deployments, the deployment that was triggered by the Amazon CloudFormation stack update appears. Choose the deployment to view the Deployment history.

    
                            Console screenshot showing the Deployments section and
                                deployment history.
  3. Choose the deployment to view the traffic shifting status. Note that the application and deployment group are not created.

    
                            Console screenshot showing the deployment details with
                                deployment status completed.
  4. The following apply for rolling back or stopping the deployment:

    • The successful deployment appears in CodeDeploy and shows that the deployment was initiated by Amazon CloudFormation.

    • If you want to stop and roll back the deployment, you must cancel the stack update in Amazon CloudFormation.