skip to Main Content

I’m trying to create a deployment group for an AWS ECS deployment

I’m following the instruction that I found here: https://docs.aws.amazon.com/codedeploy/latest/userguide/deployment-groups-create-ecs.html

The only issue is the example is done through the console and I’d prefer to do it either with Cloudformation or the CLI.

So, I decided to create my template. This is my AWS::CodeDeploy::DeploymentGroup

  CDDeploymentGroup:
    Type: AWS::CodeDeploy::DeploymentGroup
    Properties: 
      ApplicationName:
        Ref: CDApp
      DeploymentConfigName: CodeDeployDefault.LambdaCanary10Percent5Minutes 
      DeploymentStyle: 
        DeploymentType: BLUE_GREEN
        DeploymentOption: WITH_TRAFFIC_CONTROL 
      LoadBalancerInfo:
        ElbInfoList: 
          - Name: !Ref LoadBalancer
        TargetGroupPairInfoList:
          - ProdTrafficRoute:
              ListenerArns: 
                - !Ref LoadBalancerListener1
          - TestTrafficRoute:
              ListenerArns:
                - !Ref LoadBalancerListener1
        TargetGroupInfoList:
          - Name: !Ref LoadBalancerTG1
          - Name: !RefLoadBalancerTG2          
      ServiceRoleArn: 
        Fn::GetAtt: [ CodeDeployRole, Arn ]

When I deploy this template, Cloudformation fails with the following error:

my-cluster UPDATE_ROLLBACK_IN_PROGRESS. The following resource(s)
failed to create: [CDDeploymentGroup, Service2].

Service2 CREATE_FAILED. Resource creation cancelled

CDDeploymentGroup CREATE_FAILED Property LoadBalancerInfo cannot be
specified.

I searched for this error and I found that CodeDeploy in Cloudformation only supports Blue/Green deployments for Lambda.

However, I was able to follow the previous document and make it work through the console.
If I can make it work using the console I should be able to make it work at least with the cli, correct?

How can I set up the Deployment Group using Cloudformation or the CLI?
This is turning me crazy.

Thanks.

2

Answers


  1. Amazon ECS blue/green deployments through CodeDeploy do not use the AWS::CodeDeploy::DeploymentGroup resource. To perform Amazon ECS blue/green deployments, use the AWS::CodeDeploy::BlueGreen hook. See Perform Amazon ECS blue/green deployments through CodeDeploy using AWS CloudFormation for more information.

    Ref : https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codedeploy-deploymentgroup.html#cfn-codedeploy-deploymentgroup-loadbalancerinfo

    Above article points to this article for more details : https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/blue-green.html

    Apparently, you’ll need to us AWS::CodeDeploy::BlueGreen hook in your CloudFormation template for ECS b/g deployments and not AWS::CodeDeploy::DeploymentGroup resource, which is applicable only for Lambda b/g deployments.

    Login or Signup to reply.
  2. I am currently creating a stack deployment that involves this cloudformation resource, got this error and managed to clear it by not declaring the ElbInfoList. The reasoning is because the Listeners have the LoadBalancerArn in their definition and this relationship will be used with the CodeDeploy:DeploymentGroup.

    I would also recommend changing where you’ve placed the target group names to the TargetGroupInfoList to sth like this;

    LoadBalancerInfo:
            TargetGroupPairInfoList:
              - ProdTrafficRoute:
                  ListenerArns:
                    - !ImportValue ProductionListener
                TestTrafficRoute:
                  ListenerArns:
                    - !ImportValue TestListener
                TargetGroups:
                  - Name: !ImportValue ECSTargetGroup1Name
                  - Name: !ImportValue ECSTargetGroup2Name
    

    You can refer to my question here for more insights,

    CodeDeploy::DeploymentGroup Error: The list of target group pairs must have exactly one pair

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search