Amazon.CodeDeploy.AmazonCodeDeployClient.CreateDeploymentGroup C# (CSharp) Method

CreateDeploymentGroup() public method

Creates a deployment group to which application revisions will be deployed.
/// The maximum number of alarms for a deployment group (10) was exceeded. /// /// The application does not exist with the applicable IAM user or AWS account. /// /// The minimum number of required application names was not specified. /// /// The deployment configuration does not exist with the applicable IAM user or AWS account. /// /// A deployment group with the specified name already exists with the applicable IAM /// user or AWS account. /// /// The deployment groups limit was exceeded. /// /// The deployment group name was not specified. /// /// The format of the alarm configuration is invalid. Possible causes include: /// ///
  • /// /// The alarm list is null. /// ///
  • /// /// The alarm object is null. /// ///
  • /// /// The alarm name is empty or null or exceeds the 255 character limit. /// ///
  • /// /// Two alarms with the same name have been specified. /// ///
  • /// /// The alarm configuration is enabled but the alarm list is empty. /// ///
/// /// The application name was specified in an invalid format. /// /// The automatic rollback configuration was specified in an invalid format. For example, /// automatic rollback is enabled but an invalid triggering event type or no event types /// were listed. /// /// The Auto Scaling group was specified in an invalid format or does not exist. /// /// The deployment configuration name was specified in an invalid format. /// /// The deployment group name was specified in an invalid format. /// /// The tag was specified in an invalid format. /// /// The service role ARN was specified in an invalid format. Or, if an Auto Scaling group /// was specified, the specified service role does not grant the appropriate permissions /// to Auto Scaling. /// /// The specified tag was specified in an invalid format. /// /// The trigger was specified in an invalid format. /// /// The limit for lifecycle hooks was exceeded. /// /// The role ID was not specified. /// /// The maximum allowed number of triggers was exceeded. ///
public CreateDeploymentGroup ( CreateDeploymentGroupRequest request ) : Amazon.CodeDeploy.Model.CreateDeploymentGroupResponse
request Amazon.CodeDeploy.Model.CreateDeploymentGroupRequest Container for the necessary parameters to execute the CreateDeploymentGroup service method.
return Amazon.CodeDeploy.Model.CreateDeploymentGroupResponse
        public CreateDeploymentGroupResponse CreateDeploymentGroup(CreateDeploymentGroupRequest request)
        {
            var marshaller = new CreateDeploymentGroupRequestMarshaller();
            var unmarshaller = CreateDeploymentGroupResponseUnmarshaller.Instance;

            return Invoke<CreateDeploymentGroupRequest,CreateDeploymentGroupResponse>(request, marshaller, unmarshaller);
        }

Usage Example

示例#1
0
        void EnsureDeploymentGroupExistsForBundle(AmazonCodeDeployClient codeDeployClient, AmazonIdentityManagementServiceClient iamClient, AmazonAutoScalingClient autoScalingClient, Role role, string deploymentGroupName)
        {
            var serviceRoleArn = role.Arn;

            if (TargetsAutoScalingDeploymentGroup)
            {
                var group =
                    autoScalingClient.DescribeAutoScalingGroups()
                        .AutoScalingGroups.FirstOrDefault(
                            asg => asg.Tags.Any(t => t.Key == "DeploymentRole" && t.Value == deploymentGroupName));

                if (group == null)
                    throw new ApplicationException(
                        string.Format("Auto scaling group with DeploymentRole {0} does not exist.", deploymentGroupName));

                try
                {
                    codeDeployClient.CreateDeploymentGroup(new CreateDeploymentGroupRequest
                    {
                        ApplicationName = CodeDeployApplicationName,
                        DeploymentGroupName = deploymentGroupName,
                        ServiceRoleArn = serviceRoleArn,
                        AutoScalingGroups = new List<string> {group.AutoScalingGroupName}
                    });
                }
                catch (DeploymentGroupAlreadyExistsException)
                {
                    // reuse a previously created deployment group with the same name
                }
            }
            else
            {
                try
                {
                    Console.WriteLine("Will assume role {0} for deployment", serviceRoleArn);
                    codeDeployClient.CreateDeploymentGroup(new CreateDeploymentGroupRequest
                    {
                        ApplicationName = CodeDeployApplicationName,
                        DeploymentGroupName = deploymentGroupName,
                        ServiceRoleArn = serviceRoleArn,
                        Ec2TagFilters = new List<EC2TagFilter>
                    {
                        new EC2TagFilter
                        {
                            Type = EC2TagFilterType.KEY_AND_VALUE,
                            Key = "DeploymentRole",
                            Value = deploymentGroupName
                        }
                    }
                    });
                }
                catch (DeploymentGroupAlreadyExistsException)
                {
                    // since this is EC2, we can reuse a previously created deployment group with the same name
                }
            }
        }
AmazonCodeDeployClient