Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

When creating a Linux AMI in AWS with CloudFormation, I can view the output of the Cloud Init scripts, for example if I have a UserData section that echoes to stdout:

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

Then /var/log/cloud-init-output.log will contain these lines:

+ echo hello, stdout
hello, stdout

What is the equivalent log file for Windows AMIs? Is it somewhere in http://169.254.169.254/, or is it a log file somewhere?

like image 240
sashoalm Avatar asked Sep 22 '17 07:09

sashoalm


2 Answers

According to the documentation you have to wrap UserData with <script></script>. The log is written to either C:\Logs or C:\Log depending on whether EC2Launch or EC2Config is used.

According to the same document, this should work on all Windows instances by default unless you expressly use 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.

Even more information is available on another question.

like image 58
kichik Avatar answered Oct 07 '22 16:10

kichik


For Windows 2016 AMIs that's C:\ProgramData\Amazon\EC2-Windows\Launch\Log\UserdataExecution.log, where ProgramData is a hidden folder...

like image 5
Lech Migdal Avatar answered Oct 07 '22 16:10

Lech Migdal