Elastic Beanstalk Autoscaling Group Lifecycle Hooks

假装没事ソ 提交于 2021-01-29 17:32:19

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/57188826/elastic-beanstalk-autoscaling-group-lifecycle-hooks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!