0

I'm using CF to create a deployment group for a CodeDeploy application, but I keep getting error that says the deployment group already exists (it does but it belongs to a different CodeDeploy application). If I manually create it, it is fine. Here is the template:

"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" : "...."
  }
},
BPm
  • 2,924
  • 11
  • 33
  • 51
  • The name of the deployment group must be unique for each application associated with the deployment group. Just confirming that your configuration as described in your question meets that requirement. – jzonthemtn Feb 29 '16 at 19:38
  • yes unique within an application, but not unique across all applications. What is troubling is that if I manually create it, it is fine. – BPm Mar 01 '16 at 09:10

2 Answers2

0
binbinlu
  • 416
  • 2
  • 5
0

The deployment group name needs to be unique if its created as part of a CF stack since its a Name Type:

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

I got around this by prepending the application name to the deployment group name.

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