Can't create ECS deployment group using CloudFormation (loadBalancerInfo error)

0

I couldn't create ECS deployment group using CloudFormation template and got error message below.

For ECS deployment group, loadBalancerInfo must not contain targetGroupInfo list (Service: AmazonCodeDeploy; Status Code: 400; Error Code: InvalidLoadBalancerInfoException; Request ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; Proxy: null)

My CFn template fragment is as follows. I commented out "TargetGroupInfoList" in response to the error message, but it didn't work. (got exactly same error message)

  # CodeDeploy Deployment groups
  DeploymentGroup:
    Type: AWS::CodeDeploy::DeploymentGroup
    Properties: 
      ApplicationName: !Ref DeployApplication
      DeploymentStyle:
        DeploymentType: BLUE_GREEN
        DeploymentOption: WITH_TRAFFIC_CONTROL
      BlueGreenDeploymentConfiguration:
        DeploymentReadyOption:
          ActionOnTimeout: CONTINUE_DEPLOYMENT
        TerminateBlueInstancesOnDeploymentSuccess:
          Action: TERMINATE
          TerminationWaitTimeInMinutes: 5
      DeploymentConfigName: CodeDeployDefault.OneAtATime
      DeploymentGroupName: myapp-dg
      ECSServices:
        - ClusterName: !Ref ECSCluster
          ServiceName: !GetAtt ECSService.Name
      LoadBalancerInfo:
        ElbInfoList: 
          - Name: !Ref ALB
#        TargetGroupInfoList:
#          - Name: !Ref TargetGroup01
#          - Name: !Ref TargetGroup02
      ServiceRoleArn: arn:aws:iam::xxxxxxxx:role/CodeDeployServiceRole

How should I define "LoadBalancerInfo" in the template?

2 回答
1
已接受的回答

I think the problem is you have 2 target groups.

Adding more than one target group to the array is not supported.

Other issue is with BLUE_GREEN -deployment type being used with ECS

AWS CloudFormation supports blue/green deployments on the AWS Lambda compute platform only.

See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codedeploy-deploymentgroup-loadbalancerinfo.html

profile picture
专家
Kallu
已回答 2 年前
  • Thanks. I understand that BLUE_GREEN deployment with ECS is not supported in the AWS CloudFormation at the moment. I think the error message was very confusing. Most people would think from this error message that "ECS deployment group" is supported, and something is wrong with the template. Maybe this message should be fixed for more clarification.

0

If you want to simplify this process for yourself you could use CLI tools that will take care of generating the CFN templates for your use-case. I write/maintain/use ECS Compose-X which allows me to do everything in a docker compose syntax. You also could look at the CDK or Copilot. Note that Blue/Green on ECS is something that is fairly restrictive, you are better off (IMHO) setting up ALB / NLB to the service (with healthcheck) + healthcheck at the container level and let CFN deal with rolling back for you. We work that way all the time and this works like a charm.

profile picture
已回答 2 年前

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

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

回答问题的准则