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 Answers
1
Accepted Answer

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
EXPERT
Kallu
answered 2 years ago
  • 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
answered 2 years ago

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