CloudFormation - CodeDeploy部署组已存在

时间:2016-02-28 17:24:19

标签: aws-code-deploy amazon-cloudformation

我使用CF为CodeDeploy应用程序创建部署组,但我一直收到错误消息,说部署组已经存在(它确实存在,但它属于不同的CodeDeploy应用程序)。如果我手动创建它,它很好。这是模板:

"DeploymentGroup": {
  "Description": "Create a deployment group",
  "DependsOn": [
    "EC2Instance"
  ],
  "Type" : "AWS::CodeDeploy::DeploymentGroup",
  "Properties" : {
    "ApplicationName" : "Foo",
    "DeploymentConfigName": "CodeDeployDefault.AllAtOnce",
    "DeploymentGroupName": "foo-group",
    "Ec2TagFilters" : [
      {
        "Key" : "Name",
        "Value" : "Foo",
        "Type" : "KEY_AND_VALUE"
      }
    ],
    "ServiceRoleArn" : "...."
  }
},

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

如果部署组名称作为CF堆栈的一部分创建,则它必须是唯一的,因为它的名称类型为:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-name.html

我通过将应用程序名称添加到部署组名称来解决这个问题。

DeploymentGroup:
  Type: "AWS::CodeDeploy::DeploymentGroup"
  Properties:
    ApplicationName: !Ref DeployApplication
    DeploymentGroupName: !Sub "${DeployApplication}_${DeploymentGroupName}"
    ServiceRoleArn: !GetAtt CodeDeployServiceRole.Arn