When I use AWS CodeDeploy in conjunction with Auto Scaling, lifecycle actions don’t complete successfully, and instances don’t launch. How do I fix this?

AWS CodeDeploy uses the concept of Life Cycle Hooks in Auto Scaling to perform its deployments. This concept can influence the sequence of instance lifecycle states for several reasons, including:

  • Failed deployments
  • Associating multiple deployment groups with a single Auto Scaling group
  • Leftover lifecycle hooks associated with deleted applications

View the scaling history of your Auto Scaling group in the Amazon EC2 console or run the AWS Command Line Interface (CLI) command describe-scaling-activities (see the examples in the documentation) and check for the following:

The following error usually signals a failed deployment:

Description: Launching a new EC2 instance: i-f362a82e. Status Reason: Instance failed to complete user's Lifecycle Action: Lifecycle Action with token 0fc62a4b-153b-4dba-9bf4-9f233e72a697 was abandoned: Lifecycle Action Completed with ABANDON Result

Cause: At 2016-07-22T16:16:56Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 2 to 3.

Failed deployments cause related lifecycle actions to fail as well. Check the AWS CodeDeploy console to find out why your deployment failed. For information about how to resolve common deployment issues, see Troubleshoot Deployment Issues.

The following error generally occurs when multiple deployment groups are associated with a single Auto Scaling group:

Description: Launching a new EC2 instance: i-649f40a2. Status Reason: Instance failed to complete user's Lifecycle Action: Lifecycle Action with token 95c60857-3c0a-4a67-8518-6dc18797e421 was abandoned: Heartbeat Timeout

Cause: At 2016-07-23T05:08:35Z an instance was started in response to a difference between desired and actual capacity, increasing the capacity from 1 to 2.

Often, when multiple deployments send commands to the AWS CodeDeploy agent at the same time, the five-minute limit in the AWS CodeDeploy timeout logic is exceeded. Consolidate these deployments in a single deployment group, and delete any unnecessary deployment groups to help ensure lifecycle hooks are removed properly.

If lifecycle hooks associated with deployment groups that have deleted applications are still active (usually because an application was deleted before its deployment groups), follow the instructions at Amazon EC2 instances in an Auto Scaling group fail to launch and receive the error “Heartbeat Timeout”.

Note: At the conclusion of a lifecycle hook, the result is either ABANDON or CONTINUE.

If the instance is launching, CONTINUE indicates that your actions were successful, and that Auto Scaling can put the instance into service. Otherwise, ABANDON indicates that your custom actions were unsuccessful, and that Auto Scaling can terminate the instance.

If the instance is terminating, both ABANDON and CONTINUE allow the instance to terminate. However, ABANDON stops any remaining actions, such as other lifecycle hooks, and CONTINUE allows any other lifecycle hooks to complete.

AWS CodeDeploy sets the default result parameter for lifecycle hooks to ABANDON but sets it to CONTINUE after a successful deployment. For more information, see Lifecycle Action Result and --default-result (string) in the Options section of put-lifecycle-hook.

Auto Scaling, AWS CodeDeploy, lifecycle hook, deployment group, timeout, heartbeat timeout, abandon result


Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center

Published: 2016-08-25