【问题标题】:Does cfn-init need to be called from UserData?是否需要从 UserData 调用 cfn-init?
【发布时间】:2017-09-11 20:30:59
【问题描述】:

似乎AWS::CloudFormation::Init 有一个配置部分,其中包含filescommands 子部分。但是Properties 中也有 Base64 编码的 UserData,它在我的示例脚本中调用 cfn-init

"Fn::Base64": {
    "Fn::Join": [
        "",
        [
            "<script>\n",
            "cfn-init.exe -v -s ", {
                "Ref": "AWS::StackId"
            },
            " -r MyInstance",
            " --region ", {
                "Ref": "AWS::Region"
            },
            "\n",
..................

我的问题是 - 您是否需要从 UserData 手动调用 cfn-init 才能执行 AWS::CloudFormation::Init 中的指令?如果是这样,那是为什么?为什么不自动启动它,以便配置部分总是在存在时执行?

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation


    【解决方案1】:

    cfn-init.exe 是 EC2 实例上的本地组件,它与 CloudFormation 堆栈通信以执行 AWS::CloudFormation::Init 部分中的命令。

    我不知道,但我认为它没有将实际脚本放入用户数据中的原因是它不想修改用户数据,以防万一你有自己的脚本。此外,从传递到 CloudFormation 脚本的参数中,要执行的命令可能是动态的。 cfn-init.exe 工具可以读取这些值,并就如何运行 AWS::CloudFormation::Init 命令做出明智的选择。

    更多关于cfn-init.exe 在此处所做的信息: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-init.html

    【讨论】:

      猜你喜欢
      • 2015-06-06
      • 2016-05-07
      • 2016-09-19
      • 1970-01-01
      • 2019-06-29
      • 1970-01-01
      • 1970-01-01
      • 2014-09-17
      • 1970-01-01
      相关资源
      最近更新 更多