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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠