Menu
AWS CloudFormation
User Guide (API Version 2010-05-15)

AWS::CodeDeploy::DeploymentGroup

The AWS::CodeDeploy::DeploymentGroup resource creates an AWS CodeDeploy deployment group that details which application revision to use and which instances your application revisions are deployed to. For more information, see CreateDeploymentGroup in the AWS CodeDeploy API Reference.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

Copy
{ "Type" : "AWS::CodeDeploy::DeploymentGroup", "Properties" : { "AlarmConfiguration" : AlarmConfiguration, "ApplicationName" : String, "AutoScalingGroups" : [ String, ... ], "Deployment" : Deployment, "DeploymentConfigName" : String, "DeploymentGroupName" : String, "Ec2TagFilters" : [ Ec2TagFilter, ... ], "OnPremisesInstanceTagFilters" : [ OnPremisesInstanceTagFilter, ... ], "ServiceRoleArn" : String, "TriggerConfigurations" : [ TriggerConfig, ... ] } }

Properties

AlarmConfiguration

Information about the alarms that are associated with the deployment group.

Required: No

Type: AWS CodeDeploy DeploymentGroup AlarmConfiguration

Update requires: No interruption

ApplicationName

The name of an AWS CodeDeploy application for this deployment group.

Required: Yes

Type: String

Update requires: Replacement

AutoScalingGroups

A list of associated Auto Scaling groups that AWS CodeDeploy automatically deploys revisions to when new instances are created. Duplicates are not allowed.

Required: No

Type: List of strings

Update requires: No interruption

Deployment

The application revision to deploy to this deployment group.

Required: No

Type: AWS CodeDeploy DeploymentGroup Deployment

Update requires: No interruption

DeploymentConfigName

A deployment configuration name or a predefined configuration name. With predefined configurations, you can deploy application revisions to one instance at a time, half of the instances at a time, or all the instances at once. For more information and valid values, see the DeploymentConfigName parameter for the CreateDeploymentGroup action in the AWS CodeDeploy API Reference.

Required: No

Type: String

Update requires: No interruption

DeploymentGroupName

A name for the deployment group. If you don't specify a name, AWS CloudFormation generates a unique physical ID and uses that ID for the deployment group name. For more information, see Name Type.

Important

If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name.

Required: No

Type: String

Update requires: Replacement

Ec2TagFilters

The EC2 tags to filter on. AWS CodeDeploy includes all instances that match the tag filter with this deployment group. Duplicates are not allowed.

Required: No

Type: List of AWS CodeDeploy DeploymentGroup Ec2TagFilters

Update requires: No interruption

OnPremisesInstanceTagFilters

The on-premises instance tags to filter on. AWS CodeDeploy includes all on-premises instances that match the tag filter with this deployment group. To register on-premises instances with AWS CodeDeploy, see Configure Existing On-Premises Instances by Using AWS CodeDeploy in the AWS CodeDeploy User Guide. Duplicates are not allowed.

Required: No

Type: List of AWS CodeDeploy DeploymentGroup OnPremisesInstanceTagFilters

Update requires: No interruption

ServiceRoleArn

A service role Amazon Resource Name (ARN) that grants AWS CodeDeploy permission to make calls to AWS services on your behalf. For more information, see Create a Service Role for AWS CodeDeploy in the AWS CodeDeploy User Guide.

Note

In some cases, you might need to add a dependency on the service role's policy. For more information, see IAM role policy in DependsOn Attribute.

Required: Yes

Type: String

Update requires: No interruption

TriggerConfigurations

Information about the notification triggers for the deployment group. Duplicates are not allowed.

Required: No

Type: List of AWS CodeDeploy DeploymentGroup TriggerConfig

Update requires: No interruption

Return Value

Ref

When you pass the logical ID of an AWS::CodeDeploy::DeploymentGroup resource to the intrinsic Ref function, the function returns the deployment group name, such as mydeploymentgroup-a123d0d1.

For more information about using the Ref function, see Ref.

Examples

Revision in GitHub

The following example creates a deployment group that is associated with Auto Scaling groups and uses an application revision that is stored in a GitHub repository. You specify the repository information as input parameters.

JSON

Copy
"DeploymentGroup" : { "Type" : "AWS::CodeDeploy::DeploymentGroup", "Properties" : { "ApplicationName" : {"Ref" : "ApplicationName"}, "AutoScalingGroups" : [ {"Ref" : "CodeDeployAutoScalingGroups" } ], "Deployment" : { "Description" : "A sample deployment", "IgnoreApplicationStopFailures" : "true", "Revision" : { "RevisionType" : "GitHub", "GitHubLocation" : { "CommitId" : {"Ref" : "CommitId"}, "Repository" : {"Ref" : "Repository"} } } }, "ServiceRoleArn" : {"Ref" : "RoleArn"} } }

YAML

Copy
DeploymentGroup: Type: "AWS::CodeDeploy::DeploymentGroup" Properties: ApplicationName: Ref: "ApplicationName" AutoScalingGroups: - Ref: CodeDeployAutoScalingGroups Deployment: Description: "A sample deployment" IgnoreApplicationStopFailures: true Revision: RevisionType: GitHub GitHubLocation: CommitId: Ref: CommitId Repository: Ref: Repository ServiceRoleArn: Ref: RoleArn

Associate EC2 Instances

The following example creates a deployment group that uses instance tags to associate EC2 instances with the deployment group. The deployment group uses an application revision that is stored in an S3 bucket.

JSON

Copy
"DeploymentGroup" : { "Type" : "AWS::CodeDeploy::DeploymentGroup", "Properties" : { "ApplicationName" : {"Ref" : "Application"}, "Deployment" : { "Description" : "First time", "IgnoreApplicationStopFailures" : "true", "Revision" : { "RevisionType" : "S3", "S3Location" : { "Bucket" : {"Ref" : "Bucket"}, "Key" : {"Ref" : "Key"}, "BundleType" : "Zip", "ETag" : {"Ref" : "ETag"}, "Version" : {"Ref" : "Version"} } } }, "Ec2TagFilters" : [{ "Key" : {"Ref" : "TagKey"}, "Value" : {"Ref" : "TagValue"}, "Type" : "KEY_AND_VALUE" }], "ServiceRoleArn" : {"Ref" : "RoleArn"} } }

YAML

Copy
DeploymentGroup: Type: "AWS::CodeDeploy::DeploymentGroup" Properties: ApplicationName: Ref: "Application" Deployment: Description: "First time" IgnoreApplicationStopFailures: true Revision: RevisionType: S3 S3Location: Bucket: Ref: Bucket Key: Ref: Key BundleType: Zip ETag: Ref: ETag Version: Ref: Version Ec2TagFilters: - Key: Ref: TagKey Value: Ref: TagValue Type: "KEY_AND_VALUE" ServiceRoleArn: Ref: RoleArn

Alarm and Trigger

The following example configures a billing alarm and a notification trigger for the deployment group.

JSON

Copy
{ "AWSTemplateFormatVersion": "2010-09-09", "Parameters": { "EC2TagKey0": { "Type": "String", "Default": "ec2TagKey0" }, "EC2TagValue0": { "Type": "String", "Default": "ec2TagValue0" }, "EC2TagKey1": { "Type": "String", "Default": "ec2TagKey1" }, "EC2TagValue1": { "Type": "String", "Default": "ec2TagValue1" }, "CodeDeployServiceRole": { "Type": "String" }, "DeploymentGroupName": { "Type": "String" } }, "Resources": { "myAlarm": { "Type": "AWS::CloudWatch::Alarm", "Properties": { "Namespace": "AWS/Billing", "MetricName": "EstimatedCharges", "Statistic": "Maximum", "Period": "21600", "EvaluationPeriods": "1", "Threshold": 1000, "ComparisonOperator": "GreaterThanThreshold" } }, "mySNSTopic": { "Type": "AWS::SNS::Topic", "Properties": {} }, "Application": { "Type": "AWS::CodeDeploy::Application" }, "DeploymentConfig": { "Type": "AWS::CodeDeploy::DeploymentConfig", "Properties": { "MinimumHealthyHosts": { "Type": "FLEET_PERCENT", "Value": "25" } } }, "DeploymentGroup": { "Type": "AWS::CodeDeploy::DeploymentGroup", "Properties": { "AlarmConfiguration": { "Alarms": [ { "Name": { "Ref": "myAlarm" } } ] }, "ApplicationName": { "Ref": "Application" }, "DeploymentConfigName": { "Ref": "DeploymentConfig" }, "DeploymentGroupName": { "Ref": "DeploymentGroupName" }, "Ec2TagFilters": [ { "Key": { "Ref": "EC2TagKey0" }, "Value": { "Ref": "EC2TagValue0" }, "Type": "KEY_AND_VALUE" }, { "Key": { "Ref": "EC2TagKey1" }, "Type": "KEY_ONLY" }, { "Value": { "Ref": "EC2TagValue1" }, "Type": "VALUE_ONLY" } ], "ServiceRoleArn": { "Ref": "CodeDeployServiceRole" }, "TriggerConfigurations": [ { "TriggerEvents": [ "DeploymentSuccess", "DeploymentRollback" ], "TriggerName": "MyTarget", "TriggerTargetArn": { "Ref": "mySNSTopic" } } ] } } } }

YAML

Copy
AWSTemplateFormatVersion: 2010-09-09 Parameters: EC2TagKey0: Type: String Default: ec2TagKey0 EC2TagValue0: Type: String Default: ec2TagValue0 EC2TagKey1: Type: String Default: ec2TagKey1 EC2TagValue1: Type: String Default: ec2TagValue1 CodeDeployServiceRole: Type: String DeploymentGroupName: Type: String Resources: myAlarm: Type: 'AWS::CloudWatch::Alarm' Properties: Namespace: AWS/Billing MetricName: EstimatedCharges Statistic: Maximum Period: '21600' EvaluationPeriods: '1' Threshold: 1000 ComparisonOperator: GreaterThanThreshold mySNSTopic: Type: 'AWS::SNS::Topic' Properties: {} Application: Type: 'AWS::CodeDeploy::Application' DeploymentConfig: Type: 'AWS::CodeDeploy::DeploymentConfig' Properties: MinimumHealthyHosts: Type: FLEET_PERCENT Value: '25' DeploymentGroup: Type: 'AWS::CodeDeploy::DeploymentGroup' Properties: AlarmConfiguration: Alarms: - Name: !Ref myAlarm ApplicationName: !Ref Application DeploymentConfigName: !Ref DeploymentConfig DeploymentGroupName: !Ref DeploymentGroupName Ec2TagFilters: - Key: !Ref EC2TagKey0 Value: !Ref EC2TagValue0 Type: KEY_AND_VALUE - Key: !Ref EC2TagKey1 Type: KEY_ONLY - Value: !Ref EC2TagValue1 Type: VALUE_ONLY ServiceRoleArn: !Ref CodeDeployServiceRole TriggerConfigurations: - TriggerEvents: - DeploymentSuccess - DeploymentRollback TriggerName: MyTarget TriggerTargetArn: !Ref mySNSTopic