本文介绍了Elastic Beanstalk自动伸缩组生命周期挂钩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将生命周期挂钩添加到我的Elastic Beanstalk的自动伸缩组中.我知道如何通过cloudformation将生命周期挂钩添加到自动伸缩组中,但是我不知道如何通过Elastic Beanstalk来完成.

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.

要在自动扩展组上创建生命周期挂钩,您需要自动扩展组的名称.由于Elastic Beanstalk资源没有ASG名称的导出,因此这似乎是不可能的.

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

Elastic Beanstalk也不允许定义此配置.它确实允许定义一个sns主题,但是似乎没有添加一个主题来更改控制台中的配置,并且扩展操作似乎也没有使用该主题.

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

如何将Lifecycle挂钩添加到我的Elastic Beanstalk应用程序中,以便终止环境可以顺利进行关闭过程?

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

推荐答案

您也许可以使用 .ebextensions 文件进一步修改此类设置.

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

这篇关于Elastic Beanstalk自动伸缩组生命周期挂钩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-22 05:52