Elastigroup Lifecycle Events

Lifecycle hooks enable you to perform custom actions by subscribing to events and perform actions against instances as Elastigrop launches or terminates them.


How Lifecycle Hooks Work

Each lifecycle event in Elastigroup is captured and can be used for different purposes. Such as running custom scripts before instance shutdown or installing software on newly launched instances.

  • Instance Launch –  When a new instance is launched in the Elastigroup.
  • Instance Terminate – When one of your instances has been scheduled for termination due to Scale Down \ Spot Termination.

     This notification will be issued prior to Instance Terminated.
  • Instance Terminated – When the instance is actually being terminated (getting shutdown signal) from the cloud provider.
  • Scale Failed – When the group hits the max capacity defined in the Elastigroup, preventing additional scale up actions from taking place.
  • Unhealthy Instance – When one of the instances in your group recognized as unhealthy according to the Health check available by the Load balancer configured in the Elastigroup.
  • Deployment Completed – When deployment process has finished successfully.
  • Group Deployment Failed – When deployment process has failed to finish with errors.
  • Group Update Completed – When the Elastigroup updated successfully. This can be useful if you would like to monitor Elastigroup updates by other users or provisioning tools.

You can perform a custom action using one or more of the following options:

Subscribe to your desired Events target to invoke a Lambda function / HTTP / Email action when a lifecycle event occurs. The event contains information about the instance that is launching or terminating, and a token that you can use to control the lifecycle action.

     "event": "<event>",
     "instanceId": "<instance-id>",
     "resourceId": "<resource-id>",
     "resourceName": "<resource-name>"

You can also customize that information using specific formatting and parameters.

     "event": "%event%",
     "resourceId": "%resource-id%",
     "resourceName": "%resource-name%",
     "myCustomeKey": "My content is set here",
     "AWS_Account_ID": "1234567890"

The following illustration shows the transitions between instance states in this process: