How do you define "COPY_AUTO_SCALING_GROUP" for CodeDeploy DeploymentGroup in CloudFormation?

0

I'm trying to convert our old CodeDeploy DeploymentGroup from an "IN_PLACE" deployment type to a "BLUE_GREEN" deployment type using CloudFormation. Everything seems to be working pretty well except that I can't seem to figure out how to configure the ASG.

I want to copy the existing ASG and have it create new EC2 instances. However, changing the "GreenFleetProvisioningOption" to use the "COPY_AUTO_SCALING_GROUP" action causes CloudFormation throw an error with the message:

Property AutoScalingGroups cannot be specified.

If I remove the "AutoScalingGroups" from the CFN template I get this error:

Exactly one AutoScaling group must be specified when selecting the COPY_AUTO_SCALING_GROUP green fleet provisioning option.

I've looked in the docs but I can't find a way to specify a single ASG. Is this a bug? If so, where do we file a bug report? Is this by design? If so, why can I configure this through the Console, or API, or CLI but not through CFN?

Here's the relevant part of my template:

    "cddgsg": {
      "Type": "AWS::CodeDeploy::DeploymentGroup",
      "Properties": {
        "AutoRollbackConfiguration": {"Enabled": true, "Events": ["DEPLOYMENT_FAILURE"]},
        "BlueGreenDeploymentConfiguration": {
          "DeploymentReadyOption": {"ActionOnTimeout": "CONTINUE_DEPLOYMENT"},
          "GreenFleetProvisioningOption": {"Action": "COPY_AUTO_SCALING_GROUP"},
          "TerminateBlueInstancesOnDeploymentSuccess": {"Action": "TERMINATE", "TerminationWaitTimeInMinutes": 1}
        },
        "DeploymentConfigName": "CodeDeployDefault.AllAtOnce",
        "DeploymentStyle": {"DeploymentOption": "WITH_TRAFFIC_CONTROL", "DeploymentType": "BLUE_GREEN"},
        "AutoScalingGroups": [{"Ref": "asgmyappsg"}],
        "ServiceRoleArn": {"Fn::GetAtt": ["iamrdeployer", "Arn"]},
        "DeploymentGroupName": "sg",
        "ApplicationName": "myapp-sg"
      }
    },
1 Answer
1
Accepted Answer

Hello.

Unfortunately, CloudFormation does not support EC2 BLUE_GREEN deployment.
https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-resource-codedeploy-deploymentgroup.html#cfn-codedeploy-deploymentgroup-deploymentstyle

For blue/green deployments, AWS CloudFormation supports deployments on Lambda compute platforms only. You can perform Amazon ECS blue/green deployments using AWS::CodeDeploy::BlueGreen hook. See Perform Amazon ECS blue/green deployments through CodeDeploy using AWS CloudFormation for more information.

profile picture
EXPERT
answered 6 months ago
profile pictureAWS
EXPERT
reviewed 6 months ago
  • I'm guessing that the fact that it mostly works is just a fluke, correct? I mean I was able to use CFN to configure almost everything about my Blue/Green deployment, except "COPY_AUTO_SCALING_GROUP" (and LoadBalancers, but I have a workaround for that one).

    Is there any thought as to when CFN might be able to support Blue/Green deployments to EC2?

  • I don't know when I will support it either. https://github.com/aws-cloudformation

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions