DescribeAutoScalingGroups() public method

Describes one or more Auto Scaling groups.
/// The NextToken value is not valid. /// /// You already have a pending update to an Auto Scaling resource (for example, a group, /// instance, or load balancer). ///
public DescribeAutoScalingGroups ( ) : DescribeAutoScalingGroupsResponse
return DescribeAutoScalingGroupsResponse
        /// <summary>
        /// Load auto scaling groups to view model with AWS data based on region selected and EC2 classic/vpc
        /// </summary>
        private void LoadAutoScalingGroups(AmazonAutoScalingClient asClient)
        {
            try
            {
                DescribeAutoScalingGroupsRequest asreq = new DescribeAutoScalingGroupsRequest();
                DescribeAutoScalingGroupsResponse asresp = asClient.DescribeAutoScalingGroups(asreq);
                Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
                {
                    vm.AutoScalingGroups.Clear();
                }));
                foreach (AutoScalingGroup asg in asresp.DescribeAutoScalingGroupsResult.AutoScalingGroups)
                {
                    if (vm.IsVpc)
                    {
                        if (!string.IsNullOrEmpty(asg.VPCZoneIdentifier) && vm.SelectedVpc != null)
                        {
                            foreach (Models.ConsoleSubnet subnet in vm.SelectedVpc.Subnets)
                            {
                                if (asg.VPCZoneIdentifier.Contains(subnet.Subnet.SubnetId))
                                {
                                    //vm.AutoScalingGroups.Add(asg);
                                    Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
                                    {
                                        vm.AutoScalingGroups.Add(new Models.ConsoleASG() { AutoScalingGroup = asg });
                                    }));
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(asg.VPCZoneIdentifier))
                        {
                            Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
                            {
                                vm.AutoScalingGroups.Add(new Models.ConsoleASG() { AutoScalingGroup = asg });
                            }));
                        }
                    }
                }

                Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
                {
                    for (int i = 0; i < vm.AutoScalingGroups.Count(); i++)
                    {
                        DescribeNotificationConfigurationsRequest nreq = new DescribeNotificationConfigurationsRequest();
                        nreq.WithAutoScalingGroupNames(vm.AutoScalingGroups[i].AutoScalingGroup.AutoScalingGroupName);
                        DescribeNotificationConfigurationsResponse nresp = asClient.DescribeNotificationConfigurations(nreq);
                        vm.AutoScalingGroups[i].NotificationConfigurations = new List<NotificationConfiguration>();
                        foreach (NotificationConfiguration nc in nresp.DescribeNotificationConfigurationsResult.NotificationConfigurations)
                        {
                            vm.AutoScalingGroups[i].NotificationConfigurations.Add(nc);
                        }
                    }
                }));
            }
            catch (Exception ex)
            {
                LogManager.LogEntry(ex.Message);
                LogManager.LogEntry(ex.StackTrace);
                throw new DataLoadingException("Error occurred loading auto scaling groups for region and environment type");
            }
        }
Exemplo n.º 2
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
                }
            }
        }