EC2 Windows用户数据:脚本未按预期运行

时间:2018-08-10 06:39:56

标签: batch-file amazon-ec2 autoscaling user-data

启动新实例时,我需要运行自定义脚本。最低实例配置为2,因此我始终有2个实例在运行。

我执行了以下步骤来配置和检查用户数据;

  1. 创建一个实例(例如instance1)的AMI。
  2. 从现有配置中复制启动配置,并将AMI更改为我创建的新配置。
  3. 在高级详细信息中,我将用户数据粘贴了以下脚本作为示例
<script>
    echo Current date and time >> %SystemRoot%\Temp\test.log
    echo %DATE% %TIME% >> %SystemRoot%\Temp\test.log
</script>
  1. 我将自动伸缩组的启动配置更新为新的
  2. 我终止了另一个我没有参加AMI的实例,以便自动启动新实例并需要执行我的用户数据

启动后,我进入远程桌面并检查%SystemRoot%\ Temp 路径,但未创建test.log。

所以我验证了aws文档中指定的日志,并找到了以下日志

2018/06/07 00:21:01Z: Userdata execution begins
2018/06/07 00:21:01Z: Zero or more than one <persist> tag was not provided
2018/06/07 00:21:01Z: Unregistering the persist scheduled task
2018/06/07 00:21:03Z: Zero or more than one <runAsLocalSystem> tag was not provided
2018/06/07 00:21:03Z: Zero or more than one <script> tag was not provided
2018/06/07 00:21:03Z: Zero or more than one <powershellArguments> tag was not provided
2018/06/07 00:21:03Z: <powershell> tag was provided.. running powershell content
2018/06/08 09:41:39Z: Userdata execution begins
2018/06/08 09:41:39Z: Failed to get metadata: The result from http://169.254.169.254/latest/user-data was empty
2018/06/08 09:41:44Z: Unable to execute userdata: Userdata was not provided
2018/06/08 09:41:44Z: Userdata execution done
2018/06/08 10:26:28Z: Userdata execution begins
2018/06/08 10:26:28Z: Failed to get metadata: The result from http://169.254.169.254/latest/user-data was empty
2018/06/08 10:26:32Z: Unable to execute userdata: Userdata was not provided
2018/06/08 10:26:32Z: Userdata execution done

有人能帮助我错过的地方吗?

0 个答案:

没有答案