When the instance is launched from the custom AMI I could not retrieve password for the launched instance. This issue and resolution is discussed here and it worked.
These are the manual steps I performed:
- Open the Amazon EC2 console, and then connect to the original Windows EC2 instance using Remote Desktop Protocol (RDP).
- From the Windows Start menu, do the following:
For Windows Server 2008 through Windows Server 2012 R2, open EC2ConfigService Settings, and then choose the Image tab.
For Windows Server 2016 or later, open EC2 Launch Settings. - For Administrator Password, choose Random.
- Select Shutdown without Sysprep *.
- Select Yes.
- Open the Amazon EC2 console, and then select Instances.
- Wait until the instance state changes to Stopped, and then choose your instance.
- Select Actions, Image, Create image. For Image name, enter a name. (Optional) For Image description, enter a description.
- Choose Create image.
I wanted to know if steps from 1 to 5 can be automated? The source instance has the following scripts, and wondering if any of these script will do the trick, if yes, then what parameter I need to pass
"C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\SendWindowsIsReady.ps1 -Schedule",
"C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeInstance.ps1 -Schedule",
"C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\SysprepInstance.ps1 -NoShutdown"