但不断收到错误,指出部署组已经存在(它确实存在,但它属于不同的 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" : "...."
}
},
-
部署组名称对于适用的 IAM 用户或 AWS 账户必须是唯一的
-
相关文档: http://docs.aws.amazon.com/codedeploy/latest/APIReference/API_CreateDeploymentGroup.html
如果部署组名称是作为 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