micah
micah

Reputation: 8096

Elastic Beanstalk Autoscaling Group Lifecycle Hooks

I would like to add lifecycle hooks to my Elastic Beanstalk's autoscaling group. I see how lifecycle hooks can be added to an autoscaling group through cloudformation, but I don't know how this can be done through Elastic Beanstalk.

To create a lifecycle hook on an autoscaling group, you need the autoscaling group's name. This doesn't appear to be possible since the Elastic Beanstalk resource doesn't have an export for the ASG name.

Type: AWS::AutoScaling::LifecycleHook
Properties: 
  AutoScalingGroupName: String
  DefaultResult: String
  HeartbeatTimeout: Integer
  LifecycleHookName: String
  LifecycleTransition: String
  NotificationMetadata: String
  NotificationTargetARN: String
  RoleARN: String

The Elastic Beanstalk doesn't allow defining this configuration either. It does allow defining an sns topic, but adding one doesn't appear to change the configuration in the console, and scaling operations don't appear to be using this topic.

    - Namespace: aws:elasticbeanstalk:sns:topics
      OptionName: NotificationTopicARN
      Value: !ImportValue MyLifecycleHookTopic

How can I add Lifecycle hooks to my Elastic Beanstalk application, so that terminating an environment can go through my graceful shutdown process?

Upvotes: 1

Views: 1383

Answers (1)

webjunkie
webjunkie

Reputation: 7039

You might be able to use .ebextensions files to further modify settings like these.

Resources:
  lifecyclehook:
    Type: AWS::AutoScaling::LifecycleHook
    Properties:
      AutoScalingGroupName: { "Ref" : "AWSEBAutoScalingGroup" }
      LifecycleHookName: "autoscaling:EC2_INSTANCE_TERMINATING"

https://github.com/awsdocs/aws-elastic-beanstalk-developer-guide/blob/master/doc_source/environment-resources.md

Upvotes: 0

Related Questions