/// <summary> /// detact this instance from the ASG /// and decrement the ASG desired /// </summary> /// <returns></returns> private bool DetachFromAutoScalingGroup() { bool returnValue = false; using (AmazonAutoScalingClient scalingClient = new AmazonAutoScalingClient()) { DetachInstancesRequest detachRequest = new DetachInstancesRequest { AutoScalingGroupName = _AutoScalingGroupName, InstanceIds = new List <string>(new string[] { _InstanceId }), ShouldDecrementDesiredCapacity = true }; try { DetachInstancesResponse detachResponse = scalingClient.DetachInstancesAsync(detachRequest).Result; if (detachResponse.HttpStatusCode == System.Net.HttpStatusCode.OK) { returnValue = true; } } catch (Exception) { //Yes AWS throws Exceptions and System.AggregrateExceptions //so for now this is the right way to handle it returnValue = false; } } return(returnValue); }