There are more AWS SDK examples available in the AWS Doc SDK Examples
Use CreateDeploymentGroup
with a CLI
The following code examples show how to use CreateDeploymentGroup
.
- CLI
-
- AWS CLI
-
To create a deployment group
The following
create-deployment-group
example creates a deployment group and associates it with the specified application and the user's AWS account.aws deploy create-deployment-group \ --application-name
WordPress_App
\ --auto-scaling-groupsCodeDeployDemo-ASG
\ --deployment-config-nameCodeDeployDefault.OneAtATime
\ --deployment-group-nameWordPress_DG
\ --ec2-tag-filtersKey=Name,Value=CodeDeployDemo,Type=KEY_AND_VALUE
\ --service-role-arnarn:aws:iam::123456789012:role/CodeDeployDemoRole
Output:
{ "deploymentGroupId": "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE" }
-
For API details, see CreateDeploymentGroup
in AWS CLI Command Reference.
-
- PowerShell
-
- Tools for PowerShell
-
Example 1: This example creates a deployment group with the specified name, Auto Scaling group, deployment configuration, tag, and service role, for the specified application.
New-CDDeploymentGroup -ApplicationName MyNewApplication -AutoScalingGroup CodeDeployDemo-ASG -DeploymentConfigName CodeDeployDefault.OneAtATime -DeploymentGroupName MyNewDeploymentGroup -Ec2TagFilter @{Key="Name"; Type="KEY_AND_VALUE"; Value="CodeDeployDemo"} -ServiceRoleArn arn:aws:iam::80398EXAMPLE:role/CodeDeployDemo
Output:
16bbf199-95fd-40fc-a909-0bbcfEXAMPLE
Example 2: This example shows how to specify groups of EC2 instance tags that an instance must be identified by in order for it to be included in the replacement environment for a blue/green deployment.
New-CDDeploymentGroup -ApplicationName MyNewApplication -AutoScalingGroup CodeDeployDemo-ASG -DeploymentConfigName CodeDeployDefault.OneAtATime -DeploymentGroupName MyNewDeploymentGroup -Ec2TagFilter @{Key="Name"; Type="KEY_AND_VALUE"; Value="CodeDeployDemo"} -ServiceRoleArn arn:aws:iam::80398EXAMPLE:role/CodeDeployDemo -Ec2TagSetList @(@{Key="key1";Type="KEY_ONLY"},@{Key="Key2";Type="KEY_AND_VALUE";Value="Value2"}),@(@{Key="Key3";Type="VALUE_ONLY";Value="Value3"})
Output:
16bbf199-95fd-40fc-a909-0bbcfEXAMPLE
-
For API details, see CreateDeploymentGroup in AWS Tools for PowerShell Cmdlet Reference.
-