- 新しい順
- 投票が多い順
- コメントが多い順
The issue has been resolved.
I didn't understand the "shutdown with ec2launch v2 sysprep".
This is what I had to do: On the original windows instance, from the c:\progrm files\Amazon\ec2launch directory, I ran the following command: .\ec2launch.exe sysprep -s
This ran some preparatory steps and shutdown the ec2 windows instance.
I then created an new image and tried the userdata, and it worked!
Apologies, I missed an aspect of my problem description. I have updated the question with the revised info.
Hello.
The user data for the Windows instance is run using something called EC2Launch V2.
We thought that in order to run user data on a custom AMI, it might be necessary to stop the EC2 at the time of AMI creation.
https://repost.aws/knowledge-center/ec2-windows-run-command-new
Important: If you launch an instance from a custom AMI, then you must shut down the original instance that created the AMI. To do this, use EC2Launch, EC2Launch V2, or EC2Config. From the EC2Launch, EC2Launch V2, or EC2Config settings, choose Shutdown with Sysprep or Shutdown without Sysprep.
Hello,
Thanks for the above answer. I did do a shutdown of the main EC2 instance before creating the AMI image. The problem still occurs.
=> Here is some additional information that may give clues perhaps.
As noted in my post description above, the userdata script works when using the original AWS provided AMI. When I look at the C:\ProgramData\Amazon\EC2Launch\log\agent.log file for this successful scenario, I see the following lines:
2023-08-29 22:33:19 Info: Initialize user-data state.
2023-08-29 22:33:19 Info: User-data state initialized successfully.
2023-08-29 22:33:19 Info: Start script.
2023-08-29 22:33:19 Info: Frequency: once
2023-08-29 22:33:19 Info: Type: batch
2023-08-29 22:33:19 Info: Run as: admin
2023-08-29 22:33:19 Info: Not running as a detached process.
2023-08-29 22:33:19 Info: Script file is created at: C:\Windows\system32\config\systemprofile\AppData\Local\Temp\EC2Launch4107145055\UserScript.bat
2023-08-29 22:33:19 Info: Error file is created at: C:\Windows\system32\config\systemprofile\AppData\Local\Temp\EC2Launch4107145055\err.tmp
2023-08-29 22:33:19 Info: Output file is created at: C:\Windows\system32\config\systemprofile\AppData\Local\Temp\EC2Launch4107145055\output.tmp
2023-08-29 22:33:20 Info: Script execution finished successfully.
=> The audit.log complete output for the custom AMI is in my the post description above. For Custom AMI, I see the following line:
2023-08-29 20:31:14 Info: Script content detected
=> But, lines similar to the following as missing:
2023-08-29 22:33:19 Info: Script file is created at: C:\Windows\system32\config\systemprofile\AppData\Local\Temp\EC2Launch4107145055\UserScript.bat
2023-08-29 22:33:19 Info: Error file is created at: C:\Windows\system32\config\systemprofile\AppData\Local\Temp\EC2Launch4107145055\err.tmp
2023-08-29 22:33:19 Info: Output file is created at: C:\Windows\system32\config\systemprofile\AppData\Local\Temp\EC2Launch4107145055\output.tmp
2023-08-29 22:33:20 Info: Script execution finished successfully.
=> Does this give any further clue? It appears that the with custom AMI, the userdata script is recognized, but it is not executing.
関連するコンテンツ
- AWS公式更新しました 9ヶ月前
- AWS公式更新しました 6ヶ月前
- AWS公式更新しました 2年前
- AWS公式更新しました 7ヶ月前