gpt4 book ai didi

amazon-web-services - Elastic Beanstalk 中的 cfn-hup "on.demand"触发器

转载 作者:行者123 更新时间:2023-12-04 04:07:17 25 4
gpt4 key购买 nike

我已将 cfn-hup 用于各种项目,并遵循 AWS documentation对于 cfn-hup。如该页面所述,列出了以下触发器类型:

  • post.add
  • 更新后
  • post.remove

我使用这些方法取得了巨大的成功。最近,出于学习目的,我正在查看 Elastic Beanstalk CloudFormation 模板。 Elastic Beanstalk 使用 CloudFormation 来预置和引导资源。他们使用 cfn-hup,但在其配置文件中有一个奇怪的触发器类型:

"\/etc\/cfn\/hooks.d\/aws-eb-command-handler.conf":{
"content":{
"Fn::Join":[
"",
[
"[aws-eb-command-handler]",
"\n",
"triggers=on.command",
"\n",
"path=ElasticBeanstalkCommand-",
"AWSEBAutoScalingGroup",
"\n",
"action=commandWrapper.py",
"\n"
]
]
}
},

如您所见,它们具有“on.command”触发器类型。也许我是瞎子,但我在任何地方都找不到记录。这是只允许 Elastic Beanstalk 使用的特殊内部触发器类型吗?或者这只是另一个未记录的功能,如果是的话,它有什么作用?

最佳答案

这种钩子(Hook)类型确实是一种记录不足的钩子(Hook)类型。

on.command 是 CloudFormation 将 cfn-hup 命令绑定(bind)到 SQS 队列的方法。

要使用它,请在主要部分中配置您的 SQS 队列:

[main]
sqs_url=https://sqs.eu-west-1.amazonaws.com/XXXXXXXX/cfn-hook-trigger

然后,当消息发送到该队列时,您的命令将在实例上执行。消息格式如下:

{
"InvocationId": "unique",
"DispatcherId": "some value, participating in message and leader elections",
"Expiration": "1433617216000", //timestamp
"CommandName": "cfn-auto-reloader-hook", //or any other hook name
"ResultQueue": "https://eu-west-1.queue.amazonaws.com/...", // mandatory if hook.send_result was
initialized
"Data": null, //will populate ENV[CMD_DATA] env var; optional
"EventHandle": null //will populate ENV[EVENT_HANDLE] env var; optional
}

如果所选钩子(Hook)的send_result=True,则使用指定的ResultQueue来转储执行结果。消息格式如下:

{
"DispatcherId" : "copied from the inbound message",
"InvocationId" : "copied from the inbound message",
"CommandName" : "copied from the inbound message",
"Status" : "FAILURE" | "SUCCESS",
"ListenerId" : "FQDN or AWS instance id if applicable",
"Data": "STDOUT", // data > 1Kb is treated as FAILURE
"Message": "STDERR, if $? != 0" //or first 100 bytes of STDOUT if it was > 1Kb
}

此处的信息是从 python sources 中挖掘的。截至 2015 年 6 月。

未经实际测试。

此外,AWS 可能已经改变了行为,因为它甚至没有记录。

关于amazon-web-services - Elastic Beanstalk 中的 cfn-hup "on.demand"触发器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26163266/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com