/// <summary>
        /// signals AWS to move on from terminate
        /// wait by completing the action
        /// </summary>
        public bool TryCompleteTerminateWait()
        {
            bool returnValue = false;

            //Ok now  its complicated, we need the LifecycleHookName and LifecycleActionToken
            //        to complete the request, there should be a message for us in the queue
            if (!(_TerminatingLifeCycleHookName.IsNullOrWhiteSpace()))
            {
                using (AmazonAutoScalingClient scalingClient = new AmazonAutoScalingClient())
                {
                    CompleteLifecycleActionRequest completeLifecycleActionRequest = new CompleteLifecycleActionRequest
                    {
                        InstanceId            = _InstanceId,
                        LifecycleActionResult = "CONTINUE",
                        AutoScalingGroupName  = _AutoScalingGroupName,
                        LifecycleHookName     = _TerminatingLifeCycleHookName
                    };
                    try
                    {
                        CompleteLifecycleActionResponse completeLifecycleActionResponse = scalingClient.CompleteLifecycleActionAsync(completeLifecycleActionRequest).Result;
                        if (completeLifecycleActionResponse.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);
        }
Example #2
0
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            CompleteLifecycleActionResponse response = new CompleteLifecycleActionResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.IsStartElement)
                {
                    if (context.TestExpression("CompleteLifecycleActionResult", 2))
                    {
                        UnmarshallResult(context, response);
                        continue;
                    }

                    if (context.TestExpression("ResponseMetadata", 2))
                    {
                        response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context);
                    }
                }
            }

            return(response);
        }
        public static CompleteLifecycleActionResponse Unmarshall(UnmarshallerContext context)
        {
            CompleteLifecycleActionResponse completeLifecycleActionResponse = new CompleteLifecycleActionResponse();

            completeLifecycleActionResponse.HttpResponse = context.HttpResponse;
            completeLifecycleActionResponse.RequestId    = context.StringValue("CompleteLifecycleAction.RequestId");

            return(completeLifecycleActionResponse);
        }
Example #4
0
        private static void UnmarshallResult(XmlUnmarshallerContext context, CompleteLifecycleActionResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            if (context.IsStartOfDocument)
            {
                targetDepth += 2;
            }

            while (context.ReadAtDepth(originalDepth))
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                }
            }

            return;
        }