AWS CloudFormation /var/log/cloud-init-output.log 相当于 Windows 个 AMI

AWS CloudFormation /var/log/cloud-init-output.log equivalent for Windows AMIs

使用 CloudFormation 在 AWS 中创建 Linux AMI 时,我可以查看 Cloud Init 脚本的输出,例如,如果我有一个回显到标准输出的 UserData 部分:

"UserData": {
    "Fn::Base64": {
        "Fn::Join": [
            "",
            [
                "#!/bin/bash -xe\n",
                "echo hello, stdout\n"
            ]
        ]
    }
}

然后 /var/log/cloud-init-output.log 将包含这些行:

+ echo hello, stdout
hello, stdout

Windows AMI 的等效日志文件是什么?它是在 http://169.254.169.254/ 中的某处,还是某处的日志文件?

根据 documentation,您必须用 <script></script> 包裹 UserData。根据使用的是 EC2Launch 还是 EC2Config,日志将写入 C:\LogsC:\Log

根据同一文档,默认情况下这应该适用于所有 Windows 个实例,除非您明确使用 EC2Config.

By default, all Amazon AMIs have user data execution enabled for the initial boot. For instances using the EC2Config service, you can specify that user data must be executed on the next boot or restart of the service. For more information, see Ec2 Service Properties.

有关 another question 的更多信息。

对于 Windows 2016 AMI,即 C:\ProgramData\Amazon\EC2-Windows\Launch\Log\UserdataExecution.log,其中 ProgramData 是一个隐藏文件夹...