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"
      }
    },
profile picture
RNHurt
已提问 7 个月前479 查看次数
1 回答
1
已接受的回答

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
专家
已回答 7 个月前
profile pictureAWS
专家
已审核 7 个月前
  • 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

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则