示例#1
0
        public async Task ClearAutoScalingGroupAttachedTargetGroups(SA_AutoScalingGroup autoScalingGroup)
        {
            var getRequest = new DescribeLoadBalancerTargetGroupsRequest()
            {
                AutoScalingGroupName = autoScalingGroup.AutoScalingGroupName
            };
            var getResponse = await client.DescribeLoadBalancerTargetGroupsAsync(getRequest);

            if (getResponse.LoadBalancerTargetGroups.Count == 0)
            {
                return;
            }

            var removeRequest = new DetachLoadBalancerTargetGroupsRequest()
            {
                AutoScalingGroupName = autoScalingGroup.AutoScalingGroupName,
                TargetGroupARNs      = getResponse.LoadBalancerTargetGroups.ConvertAll(o => o.LoadBalancerTargetGroupARN)
            };
            await client.DetachLoadBalancerTargetGroupsAsync(removeRequest);
        }