【问题标题】:cfn-hup "on.demand" trigger in Elastic BeanstalkElastic Beanstalk 中的 cfn-hup“on.demand”触发器
【发布时间】:2014-11-27 14:04:24
【问题描述】:

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

  • post.add
  • post.update
  • 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 的一些特殊内部触发器类型吗?或者这只是另一个未记录的功能,如果是,它有什么作用?

【问题讨论】:

    标签: amazon-web-services amazon-elastic-beanstalk amazon-cloudformation


    【解决方案1】:

    这种钩子类型确实是一个文档不足的。

    on.command 是 CloudFormation 将您的 cfn-hup 命令绑定到 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
    }
    

    如果send_result=True对于选择的hook,则使用指定的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
    }
    

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

    实际上并没有经过测试。

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

    【讨论】:

      猜你喜欢
      • 2012-01-10
      • 2017-02-07
      • 2015-09-02
      • 2017-09-11
      • 2020-08-07
      • 2020-06-17
      • 1970-01-01
      • 2011-07-10
      • 1970-01-01
      相关资源
      最近更新 更多