After the VM boots, you can run remote commands on it with WinRM. Here's an example client:
https://github.com/WinRb/WinRM
Make sure WinRM is enabled in your Windows AMI and that the correct port is open in the security group.
문제
I'm having a lot of trouble trying to get a Cloud Formation template running correctly with auto scaling. I have the following resource:
"LaunchConfig" : {
"Type" : "AWS::AutoScaling::LaunchConfiguration",
"Properties" : {
"KeyName" : { "Fn::FindInMap" : [ "EnvironmentToKeyName", { "Ref" : "Environment" }, "KeyName" ] },
"ImageId" : { "Fn::FindInMap" : [ "AWSRegionToAMI", { "Ref" : "AWS::Region" }, "AMI" ] },
"SecurityGroups" : [ "neat_spi" ],
"InstanceType" : { "Ref" : "InstanceType" },
"UserData" : { "Fn::Base64" : {
"Fn::Join" : ["", [ "<script>", "call c:\\chef\\boot.bat", { "Ref" : "Environment" }, "</script>"]]
}
}
}
}
But it doesn't look like this script is running at all when the machine is started. How do I make sure it runs? Or how do I figure out why it isn't running?
I can't find any logging anywhere on how to see if this was run or not.
해결책 3
After the VM boots, you can run remote commands on it with WinRM. Here's an example client:
https://github.com/WinRb/WinRM
Make sure WinRM is enabled in your Windows AMI and that the correct port is open in the security group.
다른 팁
Couple of things to look for...
Troubleshooting CloudFormation and Userdata is time consuming - and can be costly - because you get billed for an hour every time you start and stop the instance. Something that works to great advantage for Amazon. (Bring on per minute pricing please)
I had a heck of a time getting the scripts to run on my AMI as well. It worked when I used a standard Amazon AMI, but it didn't work with my custom build AMIs.
I then found this link Create a Standard Amazon Machine Image Using Sysprep.
To summarize, I
EC2ConfigService Settings
from Start -> All Programs<script></script> or <powershell></powershell>
" on the General tab.This new AMI was able to run my UserData scripts properly.