EC2-Auto-Sacaling-Group Continuously launching and terminating the instances

0

Hi All,

I have an ASG and Codedeploygroup and lifecycle hook attached to that ASG.

Issue: My instance shuts down at then auto scaling will provision a new instance but it's continuously launching and terminating the instances.

Description: '''Launching a new EC2 instance: i-000ca10c4e05b3953. Status Reason: Instance failed to complete user's Lifecycle Action: Lifecycle Action with token 3b5aac03-8478-4fad-b012-729120c9a78e was abandoned: Lifecycle Action Completed with ABANDON Result '''

Cause: an instance was launched in response to an unhealthy instance needing to be replaced.

I know the temporary solution to it:

Remove the lifecycle hook and let the ASG spin up the instance and then deploy manually.

But can i have a permanent solution to this, so manual interruption is completely avoided?

asked 7 months ago353 views
2 Answers
0
Accepted Answer

Lifecycle Action Completed with ABANDON Result

This means an explicit ABANDON result was returned via complete-lifecycle-action (you could confirm in CloudTrail, but in these situations, its almost certainly from CodeDeploy)

You'll want to look at the DeploymentGroup and one of the individual Deployments to see what step is failing in CodeDeploy, leading to the failure.

If you need the CodeDeploy agent logs from inside the instance, you could manually send a complete-lifecycle-action call with a CONTINUE result the moment an instance is launched (and before CodeDeploy has a chance to send ABANDON). This will move the instance to InService so you can see the logs and troubleshoot it further

AWS
answered 7 months ago
0

Hello.

Certainly! The issue you're facing typically arises when the lifecycle action isn't completing successfully within the set time frame, causing the Auto Scaling group (ASG) to abandon the instance and try again. Increase the Heartbeat Timeout: By default, instances have an hour to complete the lifecycle action. If your application takes longer than this to install or initialize, the lifecycle action can be abandoned, causing the instance to terminate. Increase the heartbeat timeout to give your instances more time to initialize. https://docs.aws.amazon.com/autoscaling/ec2/userguide/lifecycle-hooks.html#:~:text=is%20one%20hour%20(-,heartbeat%20timeout,-).%20There%20is%20also

Regards, Andrii

profile picture
EXPERT
answered 7 months ago
  • Thank you for answering my question @Andrii S

    I have kept the heartbeat timeout to 10 mins. But every 2 mins my instance is getting terminated

  • When using CodeDeploy, the hook is created/managed by CodeDeploy, so its not generally a good idea to extend the heartbeat or otherwise modify the hook

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions